From 924b1cadff3f2782475516d7eca9aabe856dbf0f Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Mon, 12 Jan 2015 01:14:11 +0000 Subject: tests: avoid skipping some df tests with libmount * tests/df/no-mtab-status.sh: Provide libmount placeholders, to avoid skipping the test when libmount is in use. * tests/df/skip-duplicates.sh: Likewise. * tests/df/skip-rootfs.sh: Comment that the test is moot when libmount (/proc/self/mountinfo) is being used. --- tests/df/no-mtab-status.sh | 13 ++++++++++++- tests/df/skip-duplicates.sh | 15 +++++++++++++-- tests/df/skip-rootfs.sh | 4 +++- 3 files changed, 28 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/df/no-mtab-status.sh b/tests/df/no-mtab-status.sh index 98254f9b4..d9899c4ad 100755 --- a/tests/df/no-mtab-status.sh +++ b/tests/df/no-mtab-status.sh @@ -30,10 +30,21 @@ grep '^#define HAVE_GETMNTENT 1' $CONFIG_HEADER > /dev/null \ || skip_ "getmntent is not used on this system" # Simulate "mtab" failure. -cat > k.c <<'EOF' || framework_failure_ +cat > k.c < #include #include +#include "$CONFIG_HEADER" + +#ifdef MOUNTED_PROC_MOUNTINFO +# include +struct libmnt_table *mnt_new_table_from_file(const char *filename) +{ + /* Returning NULL here will get read_file_system_list() + to fall back to using getmntent() below. */ + return NULL; +} +#endif struct mntent *getmntent (FILE *fp) { diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh index 8cbf70039..bbd4056b7 100755 --- a/tests/df/skip-duplicates.sh +++ b/tests/df/skip-duplicates.sh @@ -23,7 +23,7 @@ require_gcc_shared_ # We use --local here so as to not activate # potentially very many remote mounts. -df --local || skip_ "df fails" +df --local || skip_ 'df fails' export CU_NONROOT_FS=$(df --local --output=target 2>&1 | grep /. | head -n1) export CU_REMOTE_FS=$(df --local --output=target 2>&1 | grep /. | @@ -40,11 +40,22 @@ grep '^#define HAVE_GETMNTENT 1' $CONFIG_HEADER > /dev/null \ || skip_ "getmntent is not used on this system" # Simulate an mtab file to test various cases. -cat > k.c <<'EOF' || framework_failure_ +cat > k.c < #include #include #include +#include "$CONFIG_HEADER" + +#ifdef MOUNTED_PROC_MOUNTINFO +# include +struct libmnt_table *mnt_new_table_from_file(const char *filename) +{ + /* Returning NULL here will get read_file_system_list() + to fall back to using getmntent() below. */ + return NULL; +} +#endif #define STREQ(a, b) (strcmp (a, b) == 0) diff --git a/tests/df/skip-rootfs.sh b/tests/df/skip-rootfs.sh index 9bb142406..ed5364eb3 100755 --- a/tests/df/skip-rootfs.sh +++ b/tests/df/skip-rootfs.sh @@ -22,8 +22,10 @@ print_ver_ df df || skip_ "df fails" # Verify that rootfs is in mtab (and shown when the -a option is specified). +# Note this is the case when /proc/self/mountinfo is parsed +# rather than /proc/mounts. I.E. when libmount is being used. df -a >out || fail=1 -grep '^rootfs' out || skip_ "no rootfs in mtab" +grep '^rootfs' out || skip_ 'no rootfs in mtab' # Ensure that rootfs is suppressed when no options is specified. df >out || fail=1 -- cgit v1.2.3-54-g00ecf