Message ID | 01dd22e13ea532321b968a79f6b88d6b4dd23e4e.1725481837.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fstests: add two tests for the precontent fanotify work | expand |
On Wed, Sep 4, 2024 at 10:33 PM Josef Bacik <josef@toxicpanda.com> wrote: > > The main purpose of putting precontent hooks in the page fault path is > to enable running an executable from a precontent watch. Add a test to > create a precontent watched directory with bash in it, and then execute > that copy of bash to validate that we fill in the pages properly and are > able to execute. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Nice! Same comments as previous patch. Thanks, Amir. > --- > tests/generic/801 | 64 +++++++++++++++++++++++++++++++++++++++++++ > tests/generic/801.out | 2 ++ > 2 files changed, 66 insertions(+) > create mode 100644 tests/generic/801 > create mode 100644 tests/generic/801.out > > diff --git a/tests/generic/801 b/tests/generic/801 > new file mode 100644 > index 00000000..7a1cc653 > --- /dev/null > +++ b/tests/generic/801 > @@ -0,0 +1,64 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2024 Meta Platforms, Inc. All Rights Reserved. > +# > +# FS QA Test 801 > +# > +# Validate the pre-content hooks work properly with exec > +# > +# Copy bash into our source directory and then setup the HSM daemon to mirror > +# into the destination directory, and execute bash from the destination > +# directory to make sure it loads properly. > +# > +. ./common/preamble > +_begin_fstest quick auto fsnotify > + > +_cleanup() > +{ > + cd / > + rm -rf $TEST_DIR/dst-$seq > + rm -rf $TEST_DIR/src-$seq > +} > + > +# real QA test starts here > +_supported_fs generic > +_require_test > +_require_test_program "precontent/populate" > +_require_test_program "precontent/remote-fetch" > + > +dstdir=$TEST_DIR/dst-$seq > +srcdir=$TEST_DIR/src-$seq > + > +POPULATE=$here/src/precontent/populate > +REMOTE_FETCH=$here/src/precontent/remote-fetch > + > +mkdir $dstdir $srcdir > + > +# Copy bash into our source dir > +cp $(which bash) $srcdir > + > +# Generate the stub file in the watch directory > +$POPULATE $srcdir $dstdir > + > +# Start the remote watcher > +$REMOTE_FETCH $srcdir $dstdir & > + > +FETCH_PID=$! > + > +# We may not support fanotify, give it a second to start and then make sure the > +# fetcher is running before we try to run our test > +sleep 1 > + > +if ! ps -p $FETCH_PID > /dev/null > +then > + _notrun "precontent watches not supported" > +fi > + > +$dstdir/bash -c "echo 'Hello!'" > + > +kill -9 $FETCH_PID &> /dev/null > +wait $FETCH_PID &> /dev/null > + > +# success, all done > +status=0 > +exit > diff --git a/tests/generic/801.out b/tests/generic/801.out > new file mode 100644 > index 00000000..98e6a16c > --- /dev/null > +++ b/tests/generic/801.out > @@ -0,0 +1,2 @@ > +QA output created by 801 > +Hello! > -- > 2.43.0 > >
diff --git a/tests/generic/801 b/tests/generic/801 new file mode 100644 index 00000000..7a1cc653 --- /dev/null +++ b/tests/generic/801 @@ -0,0 +1,64 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Meta Platforms, Inc. All Rights Reserved. +# +# FS QA Test 801 +# +# Validate the pre-content hooks work properly with exec +# +# Copy bash into our source directory and then setup the HSM daemon to mirror +# into the destination directory, and execute bash from the destination +# directory to make sure it loads properly. +# +. ./common/preamble +_begin_fstest quick auto fsnotify + +_cleanup() +{ + cd / + rm -rf $TEST_DIR/dst-$seq + rm -rf $TEST_DIR/src-$seq +} + +# real QA test starts here +_supported_fs generic +_require_test +_require_test_program "precontent/populate" +_require_test_program "precontent/remote-fetch" + +dstdir=$TEST_DIR/dst-$seq +srcdir=$TEST_DIR/src-$seq + +POPULATE=$here/src/precontent/populate +REMOTE_FETCH=$here/src/precontent/remote-fetch + +mkdir $dstdir $srcdir + +# Copy bash into our source dir +cp $(which bash) $srcdir + +# Generate the stub file in the watch directory +$POPULATE $srcdir $dstdir + +# Start the remote watcher +$REMOTE_FETCH $srcdir $dstdir & + +FETCH_PID=$! + +# We may not support fanotify, give it a second to start and then make sure the +# fetcher is running before we try to run our test +sleep 1 + +if ! ps -p $FETCH_PID > /dev/null +then + _notrun "precontent watches not supported" +fi + +$dstdir/bash -c "echo 'Hello!'" + +kill -9 $FETCH_PID &> /dev/null +wait $FETCH_PID &> /dev/null + +# success, all done +status=0 +exit diff --git a/tests/generic/801.out b/tests/generic/801.out new file mode 100644 index 00000000..98e6a16c --- /dev/null +++ b/tests/generic/801.out @@ -0,0 +1,2 @@ +QA output created by 801 +Hello!
The main purpose of putting precontent hooks in the page fault path is to enable running an executable from a precontent watch. Add a test to create a precontent watched directory with bash in it, and then execute that copy of bash to validate that we fill in the pages properly and are able to execute. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- tests/generic/801 | 64 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/801.out | 2 ++ 2 files changed, 66 insertions(+) create mode 100644 tests/generic/801 create mode 100644 tests/generic/801.out