Skip to content

Commit 70477d3

Browse files
committed
test: add configuration to check tmpfs magic
This adds a new test suite just for statfs to check that our wrapper returns the magic value for tmpfs when UNIFYFS_CLIENT_SUPER_MAGIC=0. A separate suite is required in order to change the environment under which the test runs.
1 parent f8c8658 commit 70477d3

File tree

5 files changed

+139
-0
lines changed

5 files changed

+139
-0
lines changed

t/0110-statfs-gotcha.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
#
3+
# Source sharness environment scripts to pick up test environment
4+
# and UnifyFS runtime settings.
5+
#
6+
. $(dirname $0)/sharness.d/00-test-env.sh
7+
. $(dirname $0)/sharness.d/01-unifyfs-settings.sh
8+
9+
# disable statfs from returning UnifyFS! super magic value,
10+
# return tmpfs magic instead
11+
export UNIFYFS_CLIENT_SUPER_MAGIC=0
12+
13+
$JOB_RUN_COMMAND $UNIFYFS_BUILD_DIR/t/sys/statfs-gotcha.t

t/0510-statfs-static.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
#
3+
# Source sharness environment scripts to pick up test environment
4+
# and UnifyFS runtime settings.
5+
#
6+
. $(dirname $0)/sharness.d/00-test-env.sh
7+
. $(dirname $0)/sharness.d/01-unifyfs-settings.sh
8+
9+
# disable statfs from returning UnifyFS! super magic value,
10+
# return tmpfs magic instead
11+
export UNIFYFS_CLIENT_SUPER_MAGIC=0
12+
13+
$JOB_RUN_COMMAND $UNIFYFS_BUILD_DIR/t/sys/statfs-static.t

t/Makefile.am

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ TESTS = \
1010
if HAVE_GOTCHA
1111
TESTS += \
1212
0100-sysio-gotcha.t \
13+
0110-statfs-gotcha.t \
1314
0200-stdio-gotcha.t
1415
endif
1516

1617
TESTS += \
1718
0500-sysio-static.t \
19+
0510-statfs-static.t \
1820
0600-stdio-static.t \
1921
0700-unifyfs-stage-full.t \
2022
9005-unifyfs-unmount.t \
@@ -28,6 +30,7 @@ TESTS += \
2830
check_SCRIPTS = \
2931
0001-setup.t \
3032
0500-sysio-static.t \
33+
0510-statfs-static.t \
3134
0600-stdio-static.t \
3235
0700-unifyfs-stage-full.t \
3336
9005-unifyfs-unmount.t \
@@ -41,6 +44,7 @@ check_SCRIPTS = \
4144
if HAVE_GOTCHA
4245
check_SCRIPTS += \
4346
0100-sysio-gotcha.t \
47+
0110-statfs-gotcha.t \
4448
0200-stdio-gotcha.t
4549
endif
4650

@@ -59,12 +63,14 @@ libexec_PROGRAMS = \
5963
common/seg_tree_test.t \
6064
common/slotmap_test.t \
6165
std/stdio-static.t \
66+
sys/statfs-static.t \
6267
sys/sysio-static.t \
6368
unifyfs_unmount.t
6469

6570
if HAVE_GOTCHA
6671
libexec_PROGRAMS += \
6772
std/stdio-gotcha.t \
73+
sys/statfs-gotcha.t \
6874
sys/sysio-gotcha.t
6975
endif
7076

@@ -151,6 +157,24 @@ sys_sysio_static_t_CPPFLAGS = $(test_cppflags)
151157
sys_sysio_static_t_LDADD = $(test_wrap_ldadd)
152158
sys_sysio_static_t_LDFLAGS = $(test_wrap_ldflags)
153159

160+
sys_statfs_gotcha_t_SOURCES = \
161+
sys/statfs_suite.h \
162+
sys/statfs_suite.c \
163+
sys/statfs.c
164+
165+
sys_statfs_gotcha_t_CPPFLAGS = $(test_cppflags)
166+
sys_statfs_gotcha_t_LDADD = $(test_gotcha_ldadd)
167+
sys_statfs_gotcha_t_LDFLAGS = $(test_gotcha_ldflags)
168+
169+
sys_statfs_static_t_SOURCES = \
170+
sys/statfs_suite.h \
171+
sys/statfs_suite.c \
172+
sys/statfs.c
173+
174+
sys_statfs_static_t_CPPFLAGS = $(test_cppflags)
175+
sys_statfs_static_t_LDADD = $(test_wrap_ldadd)
176+
sys_statfs_static_t_LDFLAGS = $(test_wrap_ldflags)
177+
154178
std_stdio_gotcha_t_SOURCES = \
155179
std/stdio_suite.h \
156180
std/stdio_suite.c \

t/sys/statfs_suite.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2018, Lawrence Livermore National Security, LLC.
3+
* Produced at the Lawrence Livermore National Laboratory.
4+
*
5+
* Copyright 2018, UT-Battelle, LLC.
6+
*
7+
* LLNL-CODE-741539
8+
* All rights reserved.
9+
*
10+
* This is the license for UnifyFS.
11+
* For details, see https://github.com/LLNL/UnifyFS.
12+
* Please read https://github.com/LLNL/UnifyFS/LICENSE for full license text.
13+
*/
14+
15+
#include <string.h>
16+
#include <mpi.h>
17+
#include <unifyfs.h>
18+
#include "t/lib/tap.h"
19+
#include "t/lib/testutil.h"
20+
21+
#include "statfs_suite.h"
22+
23+
/* The test suite for statfs wrappers found in client/src/unifyfs-sysio.c.
24+
*
25+
* This is specifically designed to test stafs when client super magic has
26+
* been disabled, so that statfs returns TMPFS_MAGIC. */
27+
int main(int argc, char* argv[])
28+
{
29+
int rank_num;
30+
int rank;
31+
char* unifyfs_root;
32+
int rc;
33+
34+
MPI_Init(&argc, &argv);
35+
MPI_Comm_size(MPI_COMM_WORLD, &rank_num);
36+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
37+
38+
plan(NO_PLAN);
39+
40+
unifyfs_root = testutil_get_mount_point();
41+
42+
/* Verify unifyfs_mount succeeds. */
43+
rc = unifyfs_mount(unifyfs_root, rank, rank_num, 0);
44+
ok(rc == 0, "unifyfs_mount(%s) (rc=%d)", unifyfs_root, rc);
45+
46+
/* If the mount fails, bailout, as there is no point in running the tests */
47+
if (rc != 0) {
48+
BAIL_OUT("unifyfs_mount in statfs_suite failed");
49+
}
50+
51+
/* check that statfs returns TMPFS_MAGIC
52+
* when UNIFYFS_CLIENT_SUPER_MAGIC=0 */
53+
statfs_test(unifyfs_root, 0);
54+
55+
rc = unifyfs_unmount();
56+
ok(rc == 0, "unifyfs_unmount(%s) (rc=%d)", unifyfs_root, rc);
57+
58+
MPI_Finalize();
59+
60+
done_testing();
61+
62+
return 0;
63+
}

t/sys/statfs_suite.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2018, Lawrence Livermore National Security, LLC.
3+
* Produced at the Lawrence Livermore National Laboratory.
4+
*
5+
* Copyright 2018, UT-Battelle, LLC.
6+
*
7+
* LLNL-CODE-741539
8+
* All rights reserved.
9+
*
10+
* This is the license for UnifyFS.
11+
* For details, see https://github.com/LLNL/UnifyFS.
12+
* Please read https://github.com/LLNL/UnifyFS/LICENSE for full license text.
13+
*/
14+
15+
16+
/* This test checks that statfs returns the correct value when one
17+
* has set UNIFYFS_CLIENT_SUPER_MAGIC=0. It runs as a separate
18+
* test suite because it requires a different environmental
19+
* configuration than the other tests. */
20+
#ifndef STATFS_SUITE_H
21+
#define STATFS_SUITE_H
22+
23+
/* Tests for UNIFYFS_WRAP(statfs) */
24+
int statfs_test(char* unifyfs_root, int expect_unifyfs_magic);
25+
26+
#endif /* STATFS_SUITE_H */

0 commit comments

Comments
 (0)