Skip to content

Commit 60656cb

Browse files
committed
lib: LTP_SINGLE_FS_TYPE and LTP_FORCE_SINGLE_FS_TYPE
Make the LTP_SINGE_FS_TYPE to use the test skiplists both for filesystems and fuse. This fixes the usecase where LTP users want to limit the tests with '.all_filesystems' to a single filesystem type for a testrun. The LTP_FORCE_SINGLE_FS_TYPE now replaces what previously LTP_SINGLE_FS_TYPE did and can be used for testing and for that purpose it ignores the test skiplists. Signed-off-by: Cyril Hrubis <[email protected]> Suggested-by: Petr Vorel <[email protected]> Reviewed-by: Li Wang <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Tested-by: Petr Vorel <[email protected]>
1 parent 44673a8 commit 60656cb

File tree

4 files changed

+68
-42
lines changed

4 files changed

+68
-42
lines changed

doc/users/setup_tests.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ users.
4747
printed by the test (suitable for a reproducible output).
4848

4949
* - LTP_SINGLE_FS_TYPE
50-
- Testing only - specifies filesystem instead all supported
50+
- Specifies single filesystem to run the test on instead all supported
5151
(for tests with ``.all_filesystems``).
5252

53+
* - LTP_FORCE_SINGLE_FS_TYPE
54+
- Testing only. Behaves like LTP_SINGLE_FS_TYPE but ignores test skiplists.
55+
5356
* - LTP_DEV_FS_TYPE
5457
- Filesystem used for testing (default: ``ext2``).
5558

lib/tst_supported_fs_types.c

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,40 +147,61 @@ enum tst_fs_impl tst_fs_is_supported(const char *fs_type)
147147
return TST_FS_UNSUPPORTED;
148148
}
149149

150+
static int fs_could_be_used(const char *fs_type, const char *const *skiplist,
151+
int skip_fuse)
152+
{
153+
enum tst_fs_impl sup;
154+
155+
if (tst_fs_in_skiplist(fs_type, skiplist)) {
156+
tst_res(TINFO, "Skipping %s as requested by the test",
157+
fs_type);
158+
return 0;
159+
}
160+
161+
sup = tst_fs_is_supported(fs_type);
162+
163+
if (skip_fuse && sup == TST_FS_FUSE) {
164+
tst_res(TINFO,
165+
"Skipping FUSE based %s as requested by the test",
166+
fs_type);
167+
return 0;
168+
}
169+
170+
return sup != TST_FS_UNSUPPORTED;
171+
}
172+
150173
const char **tst_get_supported_fs_types(const char *const *skiplist)
151174
{
152175
unsigned int i, j = 0;
153176
int skip_fuse;
154-
enum tst_fs_impl sup;
155-
const char *only_fs;
177+
const char *only_fs, *force_only_fs;
156178

157-
skip_fuse = tst_fs_in_skiplist("fuse", skiplist);
158179
only_fs = getenv("LTP_SINGLE_FS_TYPE");
180+
force_only_fs = getenv("LTP_FORCE_SINGLE_FS_TYPE");
181+
182+
if (only_fs && force_only_fs) {
183+
tst_brk(TBROK,
184+
"Only one of LTP_SINGLE_FS_TYPE and LTP_FORCE_SINGLE_FS_TYPE can be set");
185+
return NULL;
186+
}
187+
188+
skip_fuse = tst_fs_in_skiplist("fuse", skiplist);
159189

160190
if (only_fs) {
161191
tst_res(TINFO, "WARNING: testing only %s", only_fs);
162-
if (tst_fs_is_supported(only_fs))
192+
if (fs_could_be_used(only_fs, skiplist, skip_fuse))
163193
fs_types[0] = only_fs;
164194
return fs_types;
165195
}
166196

167-
for (i = 0; fs_type_whitelist[i]; i++) {
168-
if (tst_fs_in_skiplist(fs_type_whitelist[i], skiplist)) {
169-
tst_res(TINFO, "Skipping %s as requested by the test",
170-
fs_type_whitelist[i]);
171-
continue;
172-
}
173-
174-
sup = tst_fs_is_supported(fs_type_whitelist[i]);
175-
176-
if (skip_fuse && sup == TST_FS_FUSE) {
177-
tst_res(TINFO,
178-
"Skipping FUSE based %s as requested by the test",
179-
fs_type_whitelist[i]);
180-
continue;
181-
}
197+
if (force_only_fs) {
198+
tst_res(TINFO, "WARNING: force testing only %s", force_only_fs);
199+
fs_types[0] = force_only_fs;
200+
return fs_types;
201+
}
182202

183-
if (sup)
203+
for (i = 0; fs_type_whitelist[i]; i++) {
204+
if (fs_could_be_used(fs_type_whitelist[i], skiplist, skip_fuse))
184205
fs_types[j++] = fs_type_whitelist[i];
185206
}
186207

lib/tst_test.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -611,18 +611,19 @@ static void print_help(void)
611611
/* see doc/users/setup_tests.rst, which lists also shell API variables */
612612
fprintf(stderr, "Environment Variables\n");
613613
fprintf(stderr, "---------------------\n");
614-
fprintf(stderr, "KCONFIG_PATH Specify kernel config file\n");
615-
fprintf(stderr, "KCONFIG_SKIP_CHECK Skip kernel config check if variable set (not set by default)\n");
616-
fprintf(stderr, "LTPROOT Prefix for installed LTP (default: /opt/ltp)\n");
617-
fprintf(stderr, "LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never)\n");
618-
fprintf(stderr, "LTP_DEV Path to the block device to be used (for .needs_device)\n");
619-
fprintf(stderr, "LTP_DEV_FS_TYPE Filesystem used for testing (default: %s)\n", DEFAULT_FS_TYPE);
620-
fprintf(stderr, "LTP_REPRODUCIBLE_OUTPUT Values 1 or y discard the actual content of the messages printed by the test\n");
621-
fprintf(stderr, "LTP_SINGLE_FS_TYPE Testing only - specifies filesystem instead all supported (for .all_filesystems)\n");
622-
fprintf(stderr, "LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1)\n");
623-
fprintf(stderr, "LTP_RUNTIME_MUL Runtime multiplier (must be a number >=1)\n");
624-
fprintf(stderr, "LTP_VIRT_OVERRIDE Overrides virtual machine detection (values: \"\"|kvm|microsoft|xen|zvm)\n");
625-
fprintf(stderr, "TMPDIR Base directory for template directory (for .needs_tmpdir, default: %s)\n", TEMPDIR);
614+
fprintf(stderr, "KCONFIG_PATH Specify kernel config file\n");
615+
fprintf(stderr, "KCONFIG_SKIP_CHECK Skip kernel config check if variable set (not set by default)\n");
616+
fprintf(stderr, "LTPROOT Prefix for installed LTP (default: /opt/ltp)\n");
617+
fprintf(stderr, "LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never)\n");
618+
fprintf(stderr, "LTP_DEV Path to the block device to be used (for .needs_device)\n");
619+
fprintf(stderr, "LTP_DEV_FS_TYPE Filesystem used for testing (default: %s)\n", DEFAULT_FS_TYPE);
620+
fprintf(stderr, "LTP_REPRODUCIBLE_OUTPUT Values 1 or y discard the actual content of the messages printed by the test\n");
621+
fprintf(stderr, "LTP_SINGLE_FS_TYPE Specifies filesystem instead all supported (for .all_filesystems)\n");
622+
fprintf(stderr, "LTP_FORCE_SINGLE_FS_TYPE Testing only. The same as LTP_SINGLE_FS_TYPE but ignores test skiplist.\n");
623+
fprintf(stderr, "LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1)\n");
624+
fprintf(stderr, "LTP_RUNTIME_MUL Runtime multiplier (must be a number >=1)\n");
625+
fprintf(stderr, "LTP_VIRT_OVERRIDE Overrides virtual machine detection (values: \"\"|kvm|microsoft|xen|zvm)\n");
626+
fprintf(stderr, "TMPDIR Base directory for template directory (for .needs_tmpdir, default: %s)\n", TEMPDIR);
626627
fprintf(stderr, "\n");
627628

628629
fprintf(stderr, "Timeout and runtime\n");

testcases/lib/tst_test.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,16 @@ tst_usage()
482482
483483
Environment Variables
484484
---------------------
485-
KCONFIG_PATH Specify kernel config file
486-
KCONFIG_SKIP_CHECK Skip kernel config check if variable set (not set by default)
487-
LTPROOT Prefix for installed LTP (default: /opt/ltp)
488-
LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never)
489-
LTP_DEV Path to the block device to be used (for .needs_device)
490-
LTP_DEV_FS_TYPE Filesystem used for testing (default: ext2)
491-
LTP_SINGLE_FS_TYPE Testing only - specifies filesystem instead all supported (for TST_ALL_FILESYSTEMS=1)
492-
LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1, ceiled to int)
493-
TMPDIR Base directory for template directory (for .needs_tmpdir, default: /tmp)
485+
KCONFIG_PATH Specify kernel config file
486+
KCONFIG_SKIP_CHECK Skip kernel config check if variable set (not set by default)
487+
LTPROOT Prefix for installed LTP (default: /opt/ltp)
488+
LTP_COLORIZE_OUTPUT Force colorized output behaviour (y/1 always, n/0: never)
489+
LTP_DEV Path to the block device to be used (for .needs_device)
490+
LTP_DEV_FS_TYPE Filesystem used for testing (default: ext2)
491+
LTP_SINGLE_FS_TYPE Specifies filesystem instead all supported (for TST_ALL_FILESYSTEMS=1)
492+
LTP_FORCE_SINGLE_FS_TYPE Testing only. The same as LTP_SINGLE_FS_TYPE but ignores test skiplist
493+
LTP_TIMEOUT_MUL Timeout multiplier (must be a number >=1, ceiled to int)
494+
TMPDIR Base directory for template directory (for .needs_tmpdir, default: /tmp)
494495
EOF
495496
}
496497

0 commit comments

Comments
 (0)