Skip to contentSkip to conversation

Add read_all file systems test

PATCH Superseded Richard Palethorpe 2 participants 2 messages Feb 13, 2018 – Mar 6, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Add read_all file systems test

While using a shell script I wrote, which dumps the contents of /sys and /proc (submitted in a separate patch), I found some minor kernel bugs. There is already a test specifically for /proc however it is attempting to verify the behavior of particular files. This test is more general and can be applied to any file system.

---

V3 - Clean up some style issues and add arguments to override the number of workers.

 runtest/fs                              |   4 +
 testcases/kernel/fs/read_all/.gitignore |   1 +
 testcases/kernel/fs/read_all/Makefile   |  23 ++
 testcases/kernel/fs/read_all/read_all.c | 426 ++++++++++++++++++++++++++++++++
 4 files changed, 454 insertions(+)
 create mode 100644 testcases/kernel/fs/read_all/.gitignore
 create mode 100644 testcases/kernel/fs/read_all/Makefile
 create mode 100644 testcases/kernel/fs/read_all/read_all.c
runtest/fs +4 -0
index 3fa210a9f..a595edb98 100644
@@ -69,6 +69,10 @@ fs_di fs_di -d $TMPDIR
 # Was not sure why it should reside in runtest/crashme and won´t get tested ever
 proc01 proc01 -m 128
 
+read_all_dev read_all -d /dev -q -r 10
+read_all_proc read_all -d /proc -q -r 10
+read_all_sys read_all -d /sys -q -r 10
+
 #Run the File System Race Condition Check tests as well
 fs_racer fs_racer.sh -t 5
 
testcases/kernel/fs/read_all/.gitignore new file +1 -0
new file mode 100644
index 000000000..ac2f6ae71
@@ -0,0 +1 @@
+read_all
testcases/kernel/fs/read_all/Makefile new file +23 -0
new file mode 100644
index 000000000..efb223435
@@ -0,0 +1,23 @@
+# Copyright (c) 2017 Linux Test Project
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+CFLAGS			+= -D_GNU_SOURCE
+LDFLAGS 		+= -lpthread
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/fs/read_all/read_all.c new file +426 -0

426 lines not on this page · raw message

Signature · 1 line
2.16.1
#1 lore raw

PATCH v3 1/1 Add read_all file systems test

Hi!

testcases/kernel/fs/read_all/Makefile line 21

Quoted 2 lines
testcases/kernel/fs/read_all/Makefile new file +2 -0
+CFLAGS			+= -D_GNU_SOURCE
+LDFLAGS 		+= -lpthread

The only supported way how to compile and link with pthreads is by adding -pthread to CFLAGS (it's written in each pthread related manual page).

...

testcases/kernel/fs/read_all/read_all.c line 277

Quoted 12 lines
testcases/kernel/fs/read_all/read_all.c new file +12 -0
+static void stop_workers(void)
+{
+	const char stop_code[1] = { '\0' };
+	int i;
+
+	if (!workers)
+		return;
+
+	for (i = 0; i < worker_count; i++) {
+		if (workers[i].q)
+			queue_push(workers[i].q, stop_code);
+	}

So here we are relying on fact that there was enough space to store empty string in the queue, which will be likely true, but shouldn't we rather do something as while (!queue_push(workers[i].q, stop_code)); instead just to be sure?

I suppose that if we fail this the test will hang in tst_reap_children() because the reading threads will end up stuck in the semaphores, which is not that big deal anyways.

testcases/kernel/fs/read_all/read_all.c line 285

Quoted 7 lines
testcases/kernel/fs/read_all/read_all.c new file +7 -0
+	for (i = 0; i < worker_count; i++) {
+		if (workers[i].q) {
+			queue_destroy(workers[i].q, 0);
+			workers[i].q = 0;
+		}
+	}
+}

Other than that this looks good to me.

Signature · 2 lines
Cyril Hrubis
[email protected]