Snap for 11486189 from 921bd72620
to 24D1-release
Change-Id: I42872cfc9c0c80f8b4454a2549f7b6123c4262dc
This commit is contained in:
commit
8e9bffe03b
@ -293,6 +293,7 @@ toybox_symlinks = [
|
||||
"fsync",
|
||||
"getconf",
|
||||
"getenforce",
|
||||
"getfattr",
|
||||
"gpiodetect",
|
||||
"gpiofind",
|
||||
"gpioget",
|
||||
@ -378,6 +379,7 @@ toybox_symlinks = [
|
||||
"sendevent",
|
||||
"seq",
|
||||
"setenforce",
|
||||
"setfattr",
|
||||
"setsid",
|
||||
"sha1sum",
|
||||
"sha224sum",
|
||||
|
4
METADATA
4
METADATA
@ -9,12 +9,12 @@ third_party {
|
||||
last_upgrade_date {
|
||||
year: 2024
|
||||
month: 2
|
||||
day: 12
|
||||
day: 21
|
||||
}
|
||||
homepage: "https://landley.net/toybox/"
|
||||
identifier {
|
||||
type: "Git"
|
||||
value: "https://github.com/landley/toybox"
|
||||
version: "9f4df994dd9342f8e9a7bb11e92d28e89033a243"
|
||||
version: "b89c8914513ea055fdb686a765aaf4c65eaf706d"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/echo Try "scripts/mkroot.sh dropbear"
|
||||
#!/bin/echo Try "scripts/mkroot.sh busybox"
|
||||
|
||||
download a5d40ca0201b20909f7a8a561adf57adccc8a877 \
|
||||
http://www.busybox.net/downloads/busybox-1.36.1.tar.bz2
|
||||
|
@ -4,22 +4,27 @@
|
||||
|
||||
#testing "name" "command" "result" "infile" "stdin"
|
||||
|
||||
function clean()
|
||||
{
|
||||
# The filesystem may include some extended attributes by default (for
|
||||
# instance, security.selinux). Skip them.
|
||||
grep -v "security\."
|
||||
}
|
||||
|
||||
mkdir attrs
|
||||
touch attrs/file
|
||||
setfattr -n user.empty attrs/file
|
||||
setfattr -n user.data -v hello attrs/file
|
||||
setfattr -n user.more -v world attrs/file
|
||||
|
||||
testing "" "getfattr attrs/file" \
|
||||
testing "" "getfattr attrs/file | clean" \
|
||||
"# file: attrs/file\nuser.data\nuser.empty\nuser.more\n\n" "" ""
|
||||
testing "-d" "getfattr -d attrs/file" \
|
||||
testing "-d" "getfattr -d attrs/file | clean" \
|
||||
"# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.more=\"world\"\n\n" "" ""
|
||||
testing "-n" "getfattr -n user.empty attrs/file" \
|
||||
"# file: attrs/file\nuser.empty\n\n" "" ""
|
||||
testing "-d -n" "getfattr -d -n user.data attrs/file" \
|
||||
"# file: attrs/file\nuser.data=\"hello\"\n\n" "" ""
|
||||
testing "--only-values" "getfattr --only-values attrs/file" \
|
||||
"helloworld" "" ""
|
||||
testing "--only-values -n" "getfattr --only-values -n user.data attrs/file" \
|
||||
"hello" "" ""
|
||||
|
||||
|
65
tests/nbd-client.test
Executable file
65
tests/nbd-client.test
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
[ -f testing.sh ] && . testing.sh
|
||||
|
||||
#testing "name" "command" "result" "infile" "stdin"
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]
|
||||
then
|
||||
echo "$SHOWSKIP: nbd-client (not root)"
|
||||
return 2>/dev/null
|
||||
exit
|
||||
fi
|
||||
|
||||
# Test filesystem images
|
||||
|
||||
# truncate -s256k ext2.img; mke2fs ext2.img; bzip2 < ext2.img | base64
|
||||
base64 -d | bzcat > ext2.img << EOF
|
||||
QlpoOTFBWSZTWbBa6EkAABn//////0BEGVhI8AFKBR1FzqBiBACiQgFgAEgAAhVAZ4QMsAEYJEFN
|
||||
I0AA0AAAABoGgAGmg2ppkHMJoDQGjRhGgxGmJkxNBhGgZAMmAkiSamj0I9BMmmmEaAAAANADQGmI
|
||||
Vsb7iiy5kJkdeO7Nijja84iwwpZrgb1C54RIVpgQISiSGEk87UjHU9lMEUdeBNZVp2dNZqlfPsaF
|
||||
m1bufdAsy3r0SJadGCGluQKTCBABVYyGSUjCNaq4AABbuvG2UToQVhiJkSMCCV3QCADJbdvuYpjo
|
||||
vsnYkYkIFnzihj/ICWNlSoOYMLqmT3wO4C5ZCEAztpmAFCV0rUUwIgcB45oB+8iI/vtvYqkkWU7T
|
||||
QiPrkylDZYYRPFZQUFGmgRAFgwEygDC+o7xtv26GOcRFYzdlo2G5i0Yg1WxsQYQJJJhfrCP6DgGA
|
||||
VSH+LuSKcKEhYLXQkg==
|
||||
EOF
|
||||
|
||||
tuncate -s360k fat.img; mkfs.fat fat.img; bzip2 < fat.img | base64
|
||||
base64 -d | bzcat > fat.img << EOF
|
||||
QlpoOTFBWSZTWRzu2ngAC6j/v/C7YaDQITAEIwPHCTfv3CRAQAAUBAlAAkAABAhAC7AAu2oampqP
|
||||
SMgAGmmgAAM1AaZGE8oNU8lPU2piDQBoADQAGgaHpPUaBlIjaQAaAGgA0yaaMJk0Bo0KfAsgEkgE
|
||||
j8EGgCSAQSEwpVSi2ik+oAQCC0FJOUzrkxZikHndRLY4URVk3SAv4kdIUvCMR7xxaNBFDI63CTTL
|
||||
+9TioH4KEDXJDB1p4/uaA4CiIOROg4eLOL5FJBAk24CR6KFRyRLEdFnt1RnVbD9PKNZduYsKfdFB
|
||||
5xE1ErWAhXDDdJmXHoknmTLMhczHhSlJogGAMDGDxLOsTj+LuSKcKEgOd208AA==
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
dd if=
|
||||
testcmd "
|
||||
|
||||
echo "one" > file1
|
||||
echo "two" > file2
|
||||
testing "cat" "cat && echo yes" "oneyes\n" "" "one"
|
||||
testing "-" "cat - && echo yes" "oneyes\n" "" "one"
|
||||
testing "file1 file2" "cat file1 file2" "one\ntwo\n" "" ""
|
||||
testing "- file" "cat - file1" "zero\none\n" "" "zero\n"
|
||||
testing "file -" "cat file1 -" "one\nzero\n" "" "zero\n"
|
||||
|
||||
testing "file1 notfound file2" \
|
||||
"cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \
|
||||
"one\ntwo\ncat: notfound: No such file or directory\n" "" ""
|
||||
|
||||
testing "binary" \
|
||||
'cat "$C" > file1 && cmp "$C" file1 && echo yes' "yes\n" "" ""
|
||||
|
||||
testing "- file1" \
|
||||
"cat - file1 | diff -a -U 0 - file1 | tail -n 1" \
|
||||
"-hello\n" "" "hello\n"
|
||||
|
||||
skipnot [ -e /dev/full ]
|
||||
testing "> /dev/full" \
|
||||
"cat - > /dev/full 2>/dev/null || echo failed" \
|
||||
"failed\n" "" "zero\n"
|
||||
|
||||
rm file1 file2
|
@ -4,6 +4,13 @@
|
||||
|
||||
#testing "name" "command" "result" "infile" "stdin"
|
||||
|
||||
function clean()
|
||||
{
|
||||
# The filesystem may include some extended attributes by default (for
|
||||
# instance, security.selinux). Skip them.
|
||||
grep -v "security\."
|
||||
}
|
||||
|
||||
mkdir attrs
|
||||
touch attrs/file
|
||||
setfattr -n user.empty attrs/file
|
||||
@ -11,11 +18,11 @@ setfattr -n user.data -v hello attrs/file
|
||||
setfattr -n user.delete-me -v hello attrs/file
|
||||
|
||||
testing "-x" \
|
||||
"setfattr -x user.delete-me attrs/file && getfattr attrs/file" \
|
||||
"setfattr -x user.delete-me attrs/file && getfattr attrs/file | clean" \
|
||||
"# file: attrs/file\nuser.data\nuser.empty\n\n" "" ""
|
||||
testing "-n" "setfattr -n user.new attrs/file && getfattr -d attrs/file" \
|
||||
testing "-n" "setfattr -n user.new attrs/file && getfattr -d attrs/file | clean" \
|
||||
"# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new\n\n" "" ""
|
||||
testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -d attrs/file" \
|
||||
testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -d attrs/file | clean" \
|
||||
"# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new=\"data\"\n\n" "" ""
|
||||
|
||||
rm -rf attrs
|
||||
|
@ -86,3 +86,7 @@ testing "parallel sleep" "
|
||||
#testing "-s impossible"
|
||||
|
||||
testing "no stdin" "echo -n | xargs cat" "" "" ""
|
||||
|
||||
testing "exit 255 aborts" \
|
||||
"xargs -n1 sh -c 'echo \$1; exit \$1' blah 2>/dev/null" '123\n234\n255\n' \
|
||||
'' '123\n234\n255\n42\n99\n'
|
||||
|
@ -65,7 +65,7 @@ static speed_t speed(int baud)
|
||||
|
||||
for (i=0;i<ARRAY_LEN(bauds);i++) if (bauds[i] == baud) break;
|
||||
if (i == ARRAY_LEN(bauds)) error_exit("unknown speed: %d", baud);
|
||||
return i+4081*(i>16);
|
||||
return i+4081*(i>=16);
|
||||
}
|
||||
|
||||
struct flag {
|
||||
|
@ -98,10 +98,25 @@ static void signal_P(int sig)
|
||||
else TT.P++;
|
||||
}
|
||||
|
||||
static void waitchild(int options)
|
||||
{
|
||||
int ii, status;
|
||||
|
||||
if (1>waitpid(-1, &status, options)) return;
|
||||
TT.np--;
|
||||
ii = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+128;
|
||||
if (ii == 255) {
|
||||
error_msg("%s: exited with status 255; aborting", *toys.optargs);
|
||||
toys.exitval = 124;
|
||||
} else if ((ii|1)==127) toys.exitval = ii;
|
||||
else if (ii>127) toys.exitval = 125;
|
||||
else if (ii) toys.exitval = 123;
|
||||
}
|
||||
|
||||
void xargs_main(void)
|
||||
{
|
||||
struct double_list *dlist = 0, *dtemp;
|
||||
int entries, bytes, done = 0, status;
|
||||
int entries, bytes, done = 0;
|
||||
char *data = 0, **out = 0;
|
||||
pid_t pid = 0;
|
||||
|
||||
@ -133,10 +148,17 @@ void xargs_main(void)
|
||||
while (data || !done) {
|
||||
TT.entries = 0;
|
||||
TT.bytes = bytes;
|
||||
if (TT.np) waitchild(WNOHANG*!(TT.np==TT.P||(!data && done)));
|
||||
if (toys.exitval==124) break;
|
||||
|
||||
// Arbitrary number of execs, can't just leak memory each time...
|
||||
llist_traverse(dlist, llist_free_double);
|
||||
dlist = 0;
|
||||
free(out);
|
||||
out = 0;
|
||||
|
||||
// Loop reading input
|
||||
for (;;) {
|
||||
|
||||
// Read line
|
||||
if (!data) {
|
||||
size_t l = 0;
|
||||
@ -159,15 +181,15 @@ void xargs_main(void)
|
||||
|
||||
if (!TT.entries) {
|
||||
if (data) error_exit("argument too long");
|
||||
if (pid || FLAG(r)) goto reap_children;
|
||||
if (pid || FLAG(r)) break;
|
||||
}
|
||||
|
||||
// Fill out command line to exec
|
||||
out = xzalloc((entries+TT.entries+1)*sizeof(char *));
|
||||
memcpy(out, toys.optargs, entries*sizeof(char *));
|
||||
out = xzalloc((toys.optc+TT.entries+1)*sizeof(char *));
|
||||
memcpy(out, toys.optargs, toys.optc*sizeof(char *));
|
||||
TT.entries = 0;
|
||||
TT.bytes = bytes;
|
||||
if (dlist) dlist->prev->next = 0;
|
||||
dlist_terminate(dlist);
|
||||
for (dtemp = dlist; dtemp; dtemp = dtemp->next)
|
||||
handle_entries(dtemp->data, out+entries);
|
||||
|
||||
@ -178,7 +200,7 @@ void xargs_main(void)
|
||||
if (FLAG(p)) {
|
||||
fprintf(stderr, "?");
|
||||
if (!TT.tty) TT.tty = xfopen("/dev/tty", "re");
|
||||
if (!fyesno(TT.tty, 0)) goto reap_children;
|
||||
if (!fyesno(TT.tty, 0)) continue;
|
||||
} else fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
@ -188,29 +210,7 @@ void xargs_main(void)
|
||||
xexec(out);
|
||||
}
|
||||
TT.np++;
|
||||
|
||||
reap_children:
|
||||
while (TT.np) {
|
||||
int xv = (TT.np == TT.P) || (!data && done);
|
||||
|
||||
if (1>(xv = waitpid(-1, &status, WNOHANG*!xv))) break;
|
||||
TT.np--;
|
||||
xv = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+128;
|
||||
if (xv == 255) {
|
||||
error_msg("%s: exited with status 255; aborting", *out);
|
||||
toys.exitval = 124;
|
||||
break;
|
||||
} else if ((xv|1)==127) toys.exitval = xv;
|
||||
else if (xv>127) xv = 125;
|
||||
else if (xv) toys.exitval = 123;
|
||||
}
|
||||
|
||||
// Abritrary number of execs, can't just leak memory each time...
|
||||
llist_traverse(dlist, llist_free_double);
|
||||
dlist = 0;
|
||||
free(out);
|
||||
out = 0;
|
||||
}
|
||||
while (TT.np && -1 != wait(&status)) TT.np--;
|
||||
while (TT.np) waitchild(0);
|
||||
if (TT.tty) fclose(TT.tty);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user