Skip to content

Commit

Permalink
test: add configuration to check tmpfs magic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adammoody committed Mar 29, 2021
1 parent f8c8658 commit 70477d3
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 0 deletions.
13 changes: 13 additions & 0 deletions t/0110-statfs-gotcha.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Source sharness environment scripts to pick up test environment
# and UnifyFS runtime settings.
#
. $(dirname $0)/sharness.d/00-test-env.sh
. $(dirname $0)/sharness.d/01-unifyfs-settings.sh

# disable statfs from returning UnifyFS! super magic value,
# return tmpfs magic instead
export UNIFYFS_CLIENT_SUPER_MAGIC=0

$JOB_RUN_COMMAND $UNIFYFS_BUILD_DIR/t/sys/statfs-gotcha.t
13 changes: 13 additions & 0 deletions t/0510-statfs-static.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Source sharness environment scripts to pick up test environment
# and UnifyFS runtime settings.
#
. $(dirname $0)/sharness.d/00-test-env.sh
. $(dirname $0)/sharness.d/01-unifyfs-settings.sh

# disable statfs from returning UnifyFS! super magic value,
# return tmpfs magic instead
export UNIFYFS_CLIENT_SUPER_MAGIC=0

$JOB_RUN_COMMAND $UNIFYFS_BUILD_DIR/t/sys/statfs-static.t
24 changes: 24 additions & 0 deletions t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ TESTS = \
if HAVE_GOTCHA
TESTS += \
0100-sysio-gotcha.t \
0110-statfs-gotcha.t \
0200-stdio-gotcha.t
endif

TESTS += \
0500-sysio-static.t \
0510-statfs-static.t \
0600-stdio-static.t \
0700-unifyfs-stage-full.t \
9005-unifyfs-unmount.t \
Expand All @@ -28,6 +30,7 @@ TESTS += \
check_SCRIPTS = \
0001-setup.t \
0500-sysio-static.t \
0510-statfs-static.t \
0600-stdio-static.t \
0700-unifyfs-stage-full.t \
9005-unifyfs-unmount.t \
Expand All @@ -41,6 +44,7 @@ check_SCRIPTS = \
if HAVE_GOTCHA
check_SCRIPTS += \
0100-sysio-gotcha.t \
0110-statfs-gotcha.t \
0200-stdio-gotcha.t
endif

Expand All @@ -59,12 +63,14 @@ libexec_PROGRAMS = \
common/seg_tree_test.t \
common/slotmap_test.t \
std/stdio-static.t \
sys/statfs-static.t \
sys/sysio-static.t \
unifyfs_unmount.t

if HAVE_GOTCHA
libexec_PROGRAMS += \
std/stdio-gotcha.t \
sys/statfs-gotcha.t \
sys/sysio-gotcha.t
endif

Expand Down Expand Up @@ -151,6 +157,24 @@ sys_sysio_static_t_CPPFLAGS = $(test_cppflags)
sys_sysio_static_t_LDADD = $(test_wrap_ldadd)
sys_sysio_static_t_LDFLAGS = $(test_wrap_ldflags)

sys_statfs_gotcha_t_SOURCES = \
sys/statfs_suite.h \
sys/statfs_suite.c \
sys/statfs.c

sys_statfs_gotcha_t_CPPFLAGS = $(test_cppflags)
sys_statfs_gotcha_t_LDADD = $(test_gotcha_ldadd)
sys_statfs_gotcha_t_LDFLAGS = $(test_gotcha_ldflags)

sys_statfs_static_t_SOURCES = \
sys/statfs_suite.h \
sys/statfs_suite.c \
sys/statfs.c

sys_statfs_static_t_CPPFLAGS = $(test_cppflags)
sys_statfs_static_t_LDADD = $(test_wrap_ldadd)
sys_statfs_static_t_LDFLAGS = $(test_wrap_ldflags)

std_stdio_gotcha_t_SOURCES = \
std/stdio_suite.h \
std/stdio_suite.c \
Expand Down
63 changes: 63 additions & 0 deletions t/sys/statfs_suite.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2018, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
*
* Copyright 2018, UT-Battelle, LLC.
*
* LLNL-CODE-741539
* All rights reserved.
*
* This is the license for UnifyFS.
* For details, see https://github.com/LLNL/UnifyFS.
* Please read https://github.com/LLNL/UnifyFS/LICENSE for full license text.
*/

#include <string.h>
#include <mpi.h>
#include <unifyfs.h>
#include "t/lib/tap.h"
#include "t/lib/testutil.h"

#include "statfs_suite.h"

/* The test suite for statfs wrappers found in client/src/unifyfs-sysio.c.
*
* This is specifically designed to test stafs when client super magic has
* been disabled, so that statfs returns TMPFS_MAGIC. */
int main(int argc, char* argv[])
{
int rank_num;
int rank;
char* unifyfs_root;
int rc;

MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &rank_num);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

plan(NO_PLAN);

unifyfs_root = testutil_get_mount_point();

/* Verify unifyfs_mount succeeds. */
rc = unifyfs_mount(unifyfs_root, rank, rank_num, 0);
ok(rc == 0, "unifyfs_mount(%s) (rc=%d)", unifyfs_root, rc);

/* If the mount fails, bailout, as there is no point in running the tests */
if (rc != 0) {
BAIL_OUT("unifyfs_mount in statfs_suite failed");
}

/* check that statfs returns TMPFS_MAGIC
* when UNIFYFS_CLIENT_SUPER_MAGIC=0 */
statfs_test(unifyfs_root, 0);

rc = unifyfs_unmount();
ok(rc == 0, "unifyfs_unmount(%s) (rc=%d)", unifyfs_root, rc);

MPI_Finalize();

done_testing();

return 0;
}
26 changes: 26 additions & 0 deletions t/sys/statfs_suite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2018, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
*
* Copyright 2018, UT-Battelle, LLC.
*
* LLNL-CODE-741539
* All rights reserved.
*
* This is the license for UnifyFS.
* For details, see https://github.com/LLNL/UnifyFS.
* Please read https://github.com/LLNL/UnifyFS/LICENSE for full license text.
*/


/* This test checks that statfs returns the correct value when one
* has set UNIFYFS_CLIENT_SUPER_MAGIC=0. It runs as a separate
* test suite because it requires a different environmental
* configuration than the other tests. */
#ifndef STATFS_SUITE_H
#define STATFS_SUITE_H

/* Tests for UNIFYFS_WRAP(statfs) */
int statfs_test(char* unifyfs_root, int expect_unifyfs_magic);

#endif /* STATFS_SUITE_H */

0 comments on commit 70477d3

Please sign in to comment.