[PATCH 2/2] fstests: add a test for executing from a precontent watch directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux