diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-12-24 18:33:33 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-12-24 18:48:35 -0500 |
commit | 5daa8f40978f03ea1ae96f2dff48e7219ad6fff4 (patch) | |
tree | 43d06be66fd3559c9e0cac10c6cefad832a46b4f /tests | |
parent | libsandbox: fall back to tracing set*id programs (diff) | |
download | sandbox-5daa8f40978f03ea1ae96f2dff48e7219ad6fff4.tar.gz sandbox-5daa8f40978f03ea1ae96f2dff48e7219ad6fff4.tar.bz2 sandbox-5daa8f40978f03ea1ae96f2dff48e7219ad6fff4.zip |
tests: expand usage strings
Makes it easier to quickly figure out how to run a helper test
without having to resort to existing usage or the code itself.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/access-0.c | 8 | ||||
-rw-r--r-- | tests/faccessat-0.c | 5 | ||||
-rw-r--r-- | tests/fchmodat-0.c | 2 | ||||
-rw-r--r-- | tests/fchownat-0.c | 2 | ||||
-rw-r--r-- | tests/fopen-0.c | 2 | ||||
-rw-r--r-- | tests/fopen64-0.c | 2 | ||||
-rw-r--r-- | tests/futimesat-0.c | 2 | ||||
-rw-r--r-- | tests/link-0.c | 2 | ||||
-rw-r--r-- | tests/linkat-0.c | 2 | ||||
-rw-r--r-- | tests/lutimes-0.c | 2 | ||||
-rw-r--r-- | tests/mkostemp-0.c | 2 | ||||
-rw-r--r-- | tests/mkostemp64-0.c | 2 | ||||
-rw-r--r-- | tests/mkostemps-0.c | 2 | ||||
-rw-r--r-- | tests/mkostemps64-0.c | 2 | ||||
-rw-r--r-- | tests/open-0.c | 2 | ||||
-rw-r--r-- | tests/open64-0.c | 2 | ||||
-rw-r--r-- | tests/openat-0.c | 2 | ||||
-rw-r--r-- | tests/openat64-0.c | 2 | ||||
-rw-r--r-- | tests/rename-0.c | 2 | ||||
-rw-r--r-- | tests/renameat-0.c | 2 | ||||
-rw-r--r-- | tests/symlink-0.c | 2 | ||||
-rw-r--r-- | tests/symlinkat-0.c | 2 | ||||
-rw-r--r-- | tests/test-skel-0.c | 41 | ||||
-rw-r--r-- | tests/truncate-0.c | 2 | ||||
-rw-r--r-- | tests/truncate64-0.c | 2 | ||||
-rw-r--r-- | tests/unlinkat-0.c | 2 | ||||
-rw-r--r-- | tests/utime-0.c | 2 | ||||
-rw-r--r-- | tests/utimensat-0.c | 2 | ||||
-rw-r--r-- | tests/utimes-0.c | 2 |
29 files changed, 70 insertions, 36 deletions
diff --git a/tests/access-0.c b/tests/access-0.c index 91507e0..fd03177 100644 --- a/tests/access-0.c +++ b/tests/access-0.c @@ -3,17 +3,13 @@ #define FUNC_STR "\"%s\", %x" #define FUNC_IMP file, mode #define ARG_CNT 2 -#define ARG_USE "<file> <mode>" +#define ARG_USE "<file> <acc_mode>" #define process_args() \ s = argv[i++]; \ const char *file = f_get_file(s); \ \ s = argv[i++]; \ - int mode = 0; \ - if (strchr(s, 'r')) mode |= R_OK; \ - if (strchr(s, 'w')) mode |= W_OK; \ - if (strchr(s, 'x')) mode |= X_OK; \ - if (strchr(s, 'f')) mode = F_OK; + int mode = access_mode(s); #include "test-skel-0.c" diff --git a/tests/faccessat-0.c b/tests/faccessat-0.c index e348984..98ea2ec 100644 --- a/tests/faccessat-0.c +++ b/tests/faccessat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %x, %x" #define FUNC_IMP dirfd, file, mode, flags #define ARG_CNT 4 -#define ARG_USE "<dirfd> <file> <mode> <flags>" +#define ARG_USE "<dirfd> <file> <acc_mode> <atflags>" #define process_args() \ s = argv[i++]; \ @@ -14,8 +14,7 @@ const char *file = f_get_file(s); \ \ s = argv[i++]; \ - int mode = 0; \ - sscanf(s, "%i", &mode); \ + int mode = access_mode(s); \ \ s = argv[i++]; \ int flags = at_get_flags(s); diff --git a/tests/fchmodat-0.c b/tests/fchmodat-0.c index 98ffe66..fe77a35 100644 --- a/tests/fchmodat-0.c +++ b/tests/fchmodat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %o, %x" #define FUNC_IMP dirfd, file, mode, flags #define ARG_CNT 4 -#define ARG_USE "<dirfd> <file> <mode> <flags>" +#define ARG_USE "<dirfd> <file> <mode> <atflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/fchownat-0.c b/tests/fchownat-0.c index a168e75..e47d7f3 100644 --- a/tests/fchownat-0.c +++ b/tests/fchownat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %i, %i, %x" #define FUNC_IMP dirfd, file, uid, gid, flags #define ARG_CNT 5 -#define ARG_USE "<dirfd> <file> <uid> <gid> <flags>" +#define ARG_USE "<dirfd> <file> <uid> <gid> <atflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/fopen-0.c b/tests/fopen-0.c index abf4965..e8702bf 100644 --- a/tests/fopen-0.c +++ b/tests/fopen-0.c @@ -3,7 +3,7 @@ #define FUNC_STR "\"%s\", \"%s\"" #define FUNC_IMP file, mode #define ARG_CNT 2 -#define ARG_USE "<file> <mode>" +#define ARG_USE "<file> <strmode>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/fopen64-0.c b/tests/fopen64-0.c index e7aa673..78c0fa7 100644 --- a/tests/fopen64-0.c +++ b/tests/fopen64-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", \"%s\"" #define FUNC_IMP file, mode #define ARG_CNT 2 -#define ARG_USE "<file> <mode>" +#define ARG_USE "<file> <strmode>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/futimesat-0.c b/tests/futimesat-0.c index f710e8f..6d2ae43 100644 --- a/tests/futimesat-0.c +++ b/tests/futimesat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %p" #define FUNC_IMP dirfd, file, times #define ARG_CNT 3 -#define ARG_USE "<dirfd> <file> <times:=NULL>" +#define ARG_USE "<dirfd> <file> <times>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/link-0.c b/tests/link-0.c index f5e4f88..2c7b66c 100644 --- a/tests/link-0.c +++ b/tests/link-0.c @@ -3,7 +3,7 @@ #define FUNC_STR "\"%s\", \"%s\"" #define FUNC_IMP oldpath, newpath #define ARG_CNT 2 -#define ARG_USE "<oldpath> <newpath>" +#define ARG_USE "<path>(old) <path>(new)" #define process_args() \ s = argv[i++]; \ diff --git a/tests/linkat-0.c b/tests/linkat-0.c index 8c1af52..0f729bb 100644 --- a/tests/linkat-0.c +++ b/tests/linkat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %i, \"%s\", %x" #define FUNC_IMP olddirfd, oldpath, newdirfd, newpath, flags #define ARG_CNT 5 -#define ARG_USE "<olddirfd> <oldpath> <newdirfd> <newpath> <flags>" +#define ARG_USE "<dirfd>(old) <path>(old) <dirfd>(new) <path>(new) <atflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/lutimes-0.c b/tests/lutimes-0.c index 6b7c2e3..1037438 100644 --- a/tests/lutimes-0.c +++ b/tests/lutimes-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %p" #define FUNC_IMP file, times #define ARG_CNT 2 -#define ARG_USE "<file> <times:=NULL>" +#define ARG_USE "<file> <times>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/mkostemp-0.c b/tests/mkostemp-0.c index 7445126..65cf8c2 100644 --- a/tests/mkostemp-0.c +++ b/tests/mkostemp-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %#x" #define FUNC_IMP template, flags #define ARG_CNT 2 -#define ARG_USE "<template> <flags>" +#define ARG_USE "<template> <fflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/mkostemp64-0.c b/tests/mkostemp64-0.c index 6b25c29..54e5a5b 100644 --- a/tests/mkostemp64-0.c +++ b/tests/mkostemp64-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %#x" #define FUNC_IMP template, flags #define ARG_CNT 2 -#define ARG_USE "<template> <flags>" +#define ARG_USE "<template> <fflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/mkostemps-0.c b/tests/mkostemps-0.c index 62857b8..739a491 100644 --- a/tests/mkostemps-0.c +++ b/tests/mkostemps-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %i, %#x" #define FUNC_IMP template, suffixlen, flags #define ARG_CNT 3 -#define ARG_USE "<template> <suffixlen> <flags>" +#define ARG_USE "<template> <suffixlen> <fflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/mkostemps64-0.c b/tests/mkostemps64-0.c index 146da61..9f2e5d8 100644 --- a/tests/mkostemps64-0.c +++ b/tests/mkostemps64-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %i, %#x" #define FUNC_IMP template, suffixlen, flags #define ARG_CNT 3 -#define ARG_USE "<template> <suffixlen> <flags>" +#define ARG_USE "<template> <suffixlen> <fflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/open-0.c b/tests/open-0.c index dfae46d..7c84e51 100644 --- a/tests/open-0.c +++ b/tests/open-0.c @@ -3,7 +3,7 @@ #define FUNC_STR "\"%s\", %#x, %o" #define FUNC_IMP file, flags, mode #define ARG_CNT 3 -#define ARG_USE "<file> <flags> <mode>" +#define ARG_USE "<file> <fflags> <mode>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/open64-0.c b/tests/open64-0.c index 76d2686..5000ddb 100644 --- a/tests/open64-0.c +++ b/tests/open64-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %o" #define FUNC_IMP file, flags #define ARG_CNT 2 -#define ARG_USE "<file> <flags>" +#define ARG_USE "<file> <fflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/openat-0.c b/tests/openat-0.c index 7978e11..24f230b 100644 --- a/tests/openat-0.c +++ b/tests/openat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %#x, %o" #define FUNC_IMP dirfd, file, flags, mode #define ARG_CNT 4 -#define ARG_USE "<dirfd> <file> <flags> <mode>" +#define ARG_USE "<dirfd> <file> <fflags> <mode>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/openat64-0.c b/tests/openat64-0.c index 9c707f6..9686bc9 100644 --- a/tests/openat64-0.c +++ b/tests/openat64-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %#x, %o" #define FUNC_IMP dirfd, file, flags, mode #define ARG_CNT 4 -#define ARG_USE "<dirfd> <file> <flags> <mode>" +#define ARG_USE "<dirfd> <file> <fflags> <mode>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/rename-0.c b/tests/rename-0.c index aa50f37..28fbdc9 100644 --- a/tests/rename-0.c +++ b/tests/rename-0.c @@ -3,7 +3,7 @@ #define FUNC_STR "\"%s\", \"%s\"" #define FUNC_IMP oldpath, newpath #define ARG_CNT 2 -#define ARG_USE "<oldpath> <newpath>" +#define ARG_USE "<path>(old) <path>(new)" #define process_args() \ s = argv[i++]; \ diff --git a/tests/renameat-0.c b/tests/renameat-0.c index fcb5c88..1c1cd59 100644 --- a/tests/renameat-0.c +++ b/tests/renameat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %i, \"%s\"" #define FUNC_IMP olddirfd, oldpath, newdirfd, newpath #define ARG_CNT 4 -#define ARG_USE "<olddirfd> <oldpath> <newdirfd> <newpath>" +#define ARG_USE "<dirfd>(old) <path>(old) <dirfd>(new) <path>(new)" #define process_args() \ s = argv[i++]; \ diff --git a/tests/symlink-0.c b/tests/symlink-0.c index 6ddfd0c..70f52e3 100644 --- a/tests/symlink-0.c +++ b/tests/symlink-0.c @@ -3,7 +3,7 @@ #define FUNC_STR "\"%s\", \"%s\"" #define FUNC_IMP oldpath, newpath #define ARG_CNT 2 -#define ARG_USE "<oldpath> <newpath>" +#define ARG_USE "<path>(old) <path>(new)" #define process_args() \ s = argv[i++]; \ diff --git a/tests/symlinkat-0.c b/tests/symlinkat-0.c index f668829..1e52c60 100644 --- a/tests/symlinkat-0.c +++ b/tests/symlinkat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %i, \"%s\"" #define FUNC_IMP oldpath, newdirfd, newpath #define ARG_CNT 3 -#define ARG_USE "<oldpath> <newdirfd> <newpath>" +#define ARG_USE "<path>(old) <dirfd>(new) <path>(new)" #define process_args() \ s = argv[i++]; \ diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c index 3476552..dbe60db 100644 --- a/tests/test-skel-0.c +++ b/tests/test-skel-0.c @@ -9,6 +9,9 @@ const char *color_red = "\033[31;01m"; # define CONFIG 1 #endif +#define V_TIMESPEC "NULL" +#define V_STRMODE "<r|w|a>[+bcemx] (see `man 3 fopen`)" + static bool _strtoul(const char *sul, unsigned long *ul) { char *e; @@ -34,6 +37,7 @@ static int _get_flags(const char *str_flags, const value_pair flags[]) return ret; } +#define V_FFLAGS "O_XXX flags (see `man 2 open`)" int f_get_flags(const char *str_flags) { const value_pair flags[] = { @@ -54,6 +58,7 @@ int f_get_flags(const char *str_flags) return _get_flags(str_flags, flags); } +#define V_FILE "NULL | path" const char *f_get_file(const char *str_file) { if (!strcmp(str_file, "NULL")) @@ -62,6 +67,7 @@ const char *f_get_file(const char *str_file) return str_file; } +#define V_ATFLAGS "0 | AT_SYMLINK_NOFOLLOW | AT_REMOVEDIR | AT_SYMLINK_FOLLOW | AT_EACCESS" int at_get_flags(const char *str_flags) { const value_pair flags[] = { @@ -74,6 +80,7 @@ int at_get_flags(const char *str_flags) return _get_flags(str_flags, flags); } +#define V_MODE_T "0x# (for hex) | 0# (for octal) | # (for decimal)" mode_t sscanf_mode_t(const char *str_mode) { /* some systems (like Linux) have a 32bit mode_t. Others @@ -88,6 +95,7 @@ mode_t sscanf_mode_t(const char *str_mode) return (mode_t)mode; } +#define V_DEV_T V_MODE_T dev_t sscanf_dev_t(const char *str_dev) { /* Similar issue with dev_t as mode_t. Can't assume that @@ -98,6 +106,7 @@ dev_t sscanf_dev_t(const char *str_dev) return (dev_t)dev; } +#define V_DIRFD "AT_FDCWD | fd # | path[:<flags>[:<mode>]]" int at_get_fd(const char *str_dirfd) { /* work some magic ... expected format: @@ -123,16 +132,46 @@ int at_get_fd(const char *str_dirfd) return open(str_path, f_get_flags(str_flags), sscanf_mode_t(str_mode)); } +#define V_ACCESS_MODE "r | w | x | f" +int access_mode(const char *s) +{ + int ret = 0; + if (strchr(s, 'r')) ret |= R_OK; + if (strchr(s, 'w')) ret |= W_OK; + if (strchr(s, 'x')) ret |= X_OK; + if (strchr(s, 'f')) ret = F_OK; + return ret; +} + int main(int argc, char *argv[]) { #if CONFIG int i, test_ret; if ((argc - 1) % (ARG_CNT + 1) || argc == 1) { +#define _ARG_USE "<ret> " ARG_USE printf( "usage: " SFUNC " <tests>\n" - "test: < <ret> " ARG_USE " >\n" + "test: < " _ARG_USE " >\n" + "\n" ); + const char *vusage[] = { + "<ret>", "#[,<errno>]; # is a decimal and errno can be symbolic", + "<dirfd>", V_DIRFD, + "<file>", V_FILE, + "<times>", V_TIMESPEC, + "<atflags>", V_ATFLAGS, + "<fflags>", V_FFLAGS, + "<mode>", V_MODE_T, + "<strmode>", V_STRMODE, + "<acc_mode>", V_ACCESS_MODE, + "<dev>", V_DEV_T, + "<uid>", "# (decimal)", + "<gid>", "# (decimal)", + }; + for (i = 0; i < ARRAY_SIZE(vusage); i += 2) + if (strstr(_ARG_USE, vusage[i])) + printf("%-10s := %s\n", vusage[i], vusage[i + 1]); exit(1); } diff --git a/tests/truncate-0.c b/tests/truncate-0.c index 43810a8..c510e5c 100644 --- a/tests/truncate-0.c +++ b/tests/truncate-0.c @@ -3,7 +3,7 @@ #define FUNC_STR "\"%s\", %llu" #define FUNC_IMP path, (unsigned long long)length #define ARG_CNT 2 -#define ARG_USE "<oldpath> <newpath>" +#define ARG_USE "<path> <length>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/truncate64-0.c b/tests/truncate64-0.c index 2e28332..6e1a15f 100644 --- a/tests/truncate64-0.c +++ b/tests/truncate64-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %llu" #define FUNC_IMP path, (unsigned long long)length #define ARG_CNT 2 -#define ARG_USE "<oldpath> <newpath>" +#define ARG_USE "<path> <length>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/unlinkat-0.c b/tests/unlinkat-0.c index 3653965..6bf8bd6 100644 --- a/tests/unlinkat-0.c +++ b/tests/unlinkat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %x" #define FUNC_IMP dirfd, path, flags #define ARG_CNT 3 -#define ARG_USE "<dirfd> <path> <flags>" +#define ARG_USE "<dirfd> <path> <atflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/utime-0.c b/tests/utime-0.c index 865163e..a532693 100644 --- a/tests/utime-0.c +++ b/tests/utime-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %p" #define FUNC_IMP file, times #define ARG_CNT 2 -#define ARG_USE "<file> <times:=NULL>" +#define ARG_USE "<file> <times>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/utimensat-0.c b/tests/utimensat-0.c index da1847d..431d179 100644 --- a/tests/utimensat-0.c +++ b/tests/utimensat-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "%i, \"%s\", %p, %x" #define FUNC_IMP dirfd, file, times, flags #define ARG_CNT 4 -#define ARG_USE "<dirfd> <file> <times:=NULL> <flags>" +#define ARG_USE "<dirfd> <file> <times> <atflags>" #define process_args() \ s = argv[i++]; \ diff --git a/tests/utimes-0.c b/tests/utimes-0.c index 62c8e93..366d44a 100644 --- a/tests/utimes-0.c +++ b/tests/utimes-0.c @@ -4,7 +4,7 @@ #define FUNC_STR "\"%s\", %p" #define FUNC_IMP file, times #define ARG_CNT 2 -#define ARG_USE "<file> <times:=NULL>" +#define ARG_USE "<file> <times>" #define process_args() \ s = argv[i++]; \ |