public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC] shell wrappers for tst_checkpoint
@ 2016-06-01 14:34 Stanislav Kholmanskikh
  2016-06-01 14:34 ` [LTP] [RFC PATCH 1/2] a draft for tst_checkpoint shell wrappers Stanislav Kholmanskikh
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Stanislav Kholmanskikh @ 2016-06-01 14:34 UTC (permalink / raw)
  To: ltp

Hi!

There is a need to use the tst_checkpoint interface from shell, but
we don't have wrappers for it (yet).

Patch 1 of the series contains one possible implementation for that,
patch 2 - an example of usage in the context of the memcg_functional test case.

I'd like to get some feedback from LTP users.

My primary concern is about two issues:

1. The new test API for C is cool and takes the responsibility on
   maintaining the infrastructure for tst_checkpoint. However, I couldn't find
   a way to implement something similar in shell, so I switched back to using
   two separate functions for that - TST_CHECKPOINT_SETUP, TST_CHECKPOINT_CLEANUP.

   There may be a better way...

2. What is the best location for the new supplemental binaries (tst_checkpoint_wait,
tst_checkpoint_wake)? tools/apicmds/ltpapicmd.c or separate source files in
testcases/lib/ (similar to tst_sleep)?

Thanks.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [RFC PATCH 1/2] a draft for tst_checkpoint shell wrappers
  2016-06-01 14:34 [LTP] [RFC] shell wrappers for tst_checkpoint Stanislav Kholmanskikh
@ 2016-06-01 14:34 ` Stanislav Kholmanskikh
  2016-06-01 14:34 ` [LTP] [RFC PATCH 2/2] An example of usage of " Stanislav Kholmanskikh
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Stanislav Kholmanskikh @ 2016-06-01 14:34 UTC (permalink / raw)
  To: ltp

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 testcases/lib/test.sh     |   33 ++++++++++++++++++++++++++++++++
 tools/apicmds/.gitignore  |    2 +
 tools/apicmds/Makefile    |    3 +-
 tools/apicmds/ltpapicmd.c |   46 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+), 1 deletions(-)

diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 70345e5..33af37d 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -374,6 +374,39 @@ tst_module_exists()
 	tst_brkm TCONF "Failed to find module '$mod_name'"
 }
 
+TST_CHECKPOINT_SETUP()
+{
+	local size
+
+	LTP_IPC_PATH="/dev/shm/ltp_$$"
+
+	size=$(getconf PAGESIZE)
+	if [ $? -ne 0 ]; then
+		tst_brkm TBROK "getconf PAGESIZE failed"
+	fi
+
+	ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$size" count=1
+	ROD_SILENT chmod 600 "$LTP_IPC_PATH"
+	export LTP_IPC_PATH
+}
+
+TST_CHECKPOINT_CLEANUP()
+{
+	if [ -n "$LTP_IPC_PATH" -a -f "$LTP_IPC_PATH" ]; then
+		rm -f "$LTP_IPC_PATH"
+	fi
+}
+
+TST_CHECKPOINT_WAIT()
+{
+	ROD tst_checkpoint_wait "$1" 10000
+}
+
+TST_CHECKPOINT_WAKE()
+{
+	ROD tst_checkpoint_wake "$1" 10000
+}
+
 # Check that test name is set
 if [ -z "$TCID" ]; then
 	tst_brkm TBROK "TCID is not defined"
diff --git a/tools/apicmds/.gitignore b/tools/apicmds/.gitignore
index b4f7922..de5fd4f 100644
--- a/tools/apicmds/.gitignore
+++ b/tools/apicmds/.gitignore
@@ -11,3 +11,5 @@ tst_ncpus_max
 tst_res
 tst_resm
 tst_fs_has_free
+tst_checkpoint_wait
+tst_checkpoint_wake
diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile
index 9c9472d..90e776a 100644
--- a/tools/apicmds/Makefile
+++ b/tools/apicmds/Makefile
@@ -28,7 +28,8 @@ CPPFLAGS		+= -D_GNU_SOURCE
 
 MAKE_TARGETS		:= $(addprefix tst_,brk brkm exit flush kvercmp \
 			     kvercmp2 res resm ncpus ncpus_conf ncpus_max \
-			     get_unused_port fs_has_free)
+			     get_unused_port fs_has_free \
+			     checkpoint_wait checkpoint_wake)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
 
diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
index 12a5bd5..85bcf55 100644
--- a/tools/apicmds/ltpapicmd.c
+++ b/tools/apicmds/ltpapicmd.c
@@ -69,6 +69,7 @@
  *
  */
 
+#include <errno.h>
 #include <sys/socket.h>
 #include <stdio.h>
 #include <string.h>
@@ -78,6 +79,8 @@
 #include "usctest.h"
 #include "safe_macros.h"
 
+extern void tst_reinit(void);
+
 char *TCID;			/* Name of the testcase */
 int TST_TOTAL;			/* Total number of testcases */
 
@@ -369,6 +372,45 @@ fs_has_free_err:
 	exit(2);
 }
 
+int apicmd_checkpoint_wait_or_wake(int type, int argc, char *argv[])
+{
+	unsigned long id;
+	unsigned long msec_timeout;
+	char *e;
+
+	if (argc != 3)
+		goto err;
+
+	errno = 0;
+	id = strtoul(argv[0], &e, 10);
+	if (errno || (argv[0] == e) || (id > UINT_MAX)) {
+		fprintf(stderr, "ERROR: Invalid value '%s'\n",
+			argv[0]);
+		goto err;
+	}
+
+	errno = 0;
+	msec_timeout = strtoul(argv[1], &e, 10);
+	if (errno || (argv[1] == e) || (msec_timeout > UINT_MAX)) {
+		fprintf(stderr, "ERROR: Invalid value '%s'\n",
+			argv[1]);
+		goto err;
+	}
+
+	tst_reinit();
+
+	if (!type)
+		exit(tst_checkpoint_wait(id, msec_timeout));
+	else
+		exit(tst_checkpoint_wake(id, 1, msec_timeout));
+
+err:
+	printf("Usage: %s ID TIMEOUT\n", cmd_name);
+	printf("       ID - checkpoint id\n");
+	printf("       TIMEOUT - timeout in ms\n");
+	exit(1);
+}
+
 /*
  * Function:    main - entry point of this program
  *
@@ -459,6 +501,10 @@ int main(int argc, char *argv[])
 		printf("%u\n", apicmd_get_unused_port(argc, argv));
 	} else if (strcmp(cmd_name, "tst_fs_has_free") == 0) {
 		apicmd_fs_has_free(argc, argv);
+	} else if (strcmp(cmd_name, "tst_checkpoint_wait") == 0) {
+		apicmd_checkpoint_wait_or_wake(0, argc, argv);
+	} else if (strcmp(cmd_name, "tst_checkpoint_wake") == 0) {
+		apicmd_checkpoint_wait_or_wake(1, argc, argv);
 	}
 
 	exit(0);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [RFC PATCH 2/2] An example of usage of tst_checkpoint shell wrappers
  2016-06-01 14:34 [LTP] [RFC] shell wrappers for tst_checkpoint Stanislav Kholmanskikh
  2016-06-01 14:34 ` [LTP] [RFC PATCH 1/2] a draft for tst_checkpoint shell wrappers Stanislav Kholmanskikh
@ 2016-06-01 14:34 ` Stanislav Kholmanskikh
  2016-06-01 15:12   ` Cyril Hrubis
  2016-06-01 15:03 ` [LTP] [RFC] shell wrappers for tst_checkpoint Cyril Hrubis
  2016-06-02  7:58 ` Jan Stancek
  3 siblings, 1 reply; 9+ messages in thread
From: Stanislav Kholmanskikh @ 2016-06-01 14:34 UTC (permalink / raw)
  To: ltp

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
---
 .../memcg/functional/memcg_function_test.sh        |   27 +++++++++++---------
 .../controllers/memcg/functional/memcg_lib.sh      |   16 +++++------
 .../controllers/memcg/functional/memcg_process.c   |    6 ++++
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
index 2c2f32a..efafad5 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
@@ -25,12 +25,19 @@
 ##                                                                            ##
 ################################################################################
 
-export TCID="memcg_function_test"
-export TST_TOTAL=38
-export TST_COUNT=0
-
+TCID="memcg_function_test"
+TST_TOTAL=38
+. test.sh
 . memcg_lib.sh || exit 1
 
+my_cleanup()
+{
+	TST_CHECKPOINT_CLEANUP
+}
+
+TST_CLEANUP=my_cleanup
+TST_CHECKPOINT_SETUP
+
 # Case 1 - 10: Test the management and counting of memory
 testcase_1()
 {
@@ -207,7 +214,7 @@ testcase_29()
 {
 	$TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
 	pid=$!
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
 	kill -s USR1 $pid 2> /dev/null
 	sleep 1
@@ -228,7 +235,7 @@ testcase_30()
 {
 	$TEST_PATH/memcg_process --mmap-lock2 -s $PAGESIZE &
 	pid=$!
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
 	kill -s USR1 $pid 2> /dev/null
 	sleep 1
@@ -299,7 +306,6 @@ fi
 # Run all the test cases
 for i in $(seq 1 $TST_TOTAL)
 do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
 	cur_id=$i
 
 	do_mount
@@ -325,8 +331,5 @@ done
 
 echo $shmmax > /proc/sys/kernel/shmmax
 
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
+tst_exit
+
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index 9b9b0fd..b3e6157 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -41,7 +41,6 @@ FAIL=1
 orig_memory_use_hierarchy=""
 
 cur_id=0
-failed=0
 
 # Record the test result of a test case
 # $1 - The result of the test case, $PASS or $FAIL
@@ -55,7 +54,6 @@ result()
 		tst_resm TPASS "$info"
 	else
 		tst_resm TFAIL "$info"
-		: $(( failed += 1 ))
 	fi
 }
 
@@ -111,7 +109,7 @@ test_mem_stat()
 {
 	echo "Running $TEST_PATH/memcg_process $1 -s $2"
 	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 
 	warmup $!
 	if [ $? -ne 0 ]; then
@@ -144,7 +142,7 @@ test_max_usage_in_bytes()
 {
 	echo "Running $TEST_PATH/memcg_process $1 -s $2"
 	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 
 	warmup $!
 	if [ $? -ne 0 ]; then
@@ -175,7 +173,7 @@ malloc_free_memory()
 {
 	echo "Running $TEST_PATH/memcg_process $1 -s $2"
 	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 
 	echo $! > tasks
 	kill -s USR1 $! 2> /dev/null
@@ -220,7 +218,7 @@ test_proc_kill()
 
 	$TEST_PATH/memcg_process $2 -s $3 &
 	pid=$!
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
 
 	kill -s USR1 $pid 2> /dev/null
@@ -284,7 +282,7 @@ test_hugepage()
 	echo $1 > /proc/sys/vm/nr_hugepages
 
 	$TEST_PATH/memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 
 	kill -s USR1 $! 2> /dev/null
 	sleep 1
@@ -332,7 +330,7 @@ test_subgroup()
 
 	echo "Running $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE"
 	$TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 
 	warmup $!
 	if [ $? -ne 0 ]; then
@@ -367,7 +365,7 @@ test_move_charge()
 	mkdir subgroup_a
 
 	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 	warmup $!
 	if [ $? -ne 0 ]; then
 		rmdir subgroup_a
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_process.c b/testcases/kernel/controllers/memcg/functional/memcg_process.c
index 3d34394..95e947f 100644
--- a/testcases/kernel/controllers/memcg/functional/memcg_process.c
+++ b/testcases/kernel/controllers/memcg/functional/memcg_process.c
@@ -34,6 +34,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
 
 int fd;
 
@@ -310,6 +312,10 @@ int main(int argc, char *argv[])
 
 	process_options(argc, argv);
 
+	tst_reinit();
+
+	TST_CHECKPOINT_WAKE(0);
+
 	while (!flag_exit)
 		sleep(1);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [RFC] shell wrappers for tst_checkpoint
  2016-06-01 14:34 [LTP] [RFC] shell wrappers for tst_checkpoint Stanislav Kholmanskikh
  2016-06-01 14:34 ` [LTP] [RFC PATCH 1/2] a draft for tst_checkpoint shell wrappers Stanislav Kholmanskikh
  2016-06-01 14:34 ` [LTP] [RFC PATCH 2/2] An example of usage of " Stanislav Kholmanskikh
@ 2016-06-01 15:03 ` Cyril Hrubis
  2016-06-02 14:58   ` Stanislav Kholmanskikh
  2016-06-02  7:58 ` Jan Stancek
  3 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2016-06-01 15:03 UTC (permalink / raw)
  To: ltp

Hi!
> There is a need to use the tst_checkpoint interface from shell, but
> we don't have wrappers for it (yet).
> 
> Patch 1 of the series contains one possible implementation for that,
> patch 2 - an example of usage in the context of the memcg_functional test case.
> 
> I'd like to get some feedback from LTP users.
> 
> My primary concern is about two issues:
> 
> 1. The new test API for C is cool and takes the responsibility on
>    maintaining the infrastructure for tst_checkpoint. However, I couldn't find
>    a way to implement something similar in shell, so I switched back to using
>    two separate functions for that - TST_CHECKPOINT_SETUP, TST_CHECKPOINT_CLEANUP.
> 
>    There may be a better way...

Well we can always put the cleanup into the tst_exit() which is executed
both on clean and unclean exit (tst_brkm). And the setup could be done
right after the checks for TCID and TST_TOTAL. Both supposedly if
something as TST_NEEDS_CHECKPOINTS=1 has been set before sourcing
test.sh.

Also nothing stops us from bringing the shell API closer to what we have
for C :).

We would have to source the test library script after we had defined all
the setup() cleanup() and test() functions and after setting the
corresponding TST_ID=foo, TST_NEEDS_CHECKPOINTS=1, etc. But as far as I
can tell it seems doable.

And it would be really cool if we managed to use the shared memory for
test results as well so that result from child processes (subshells)
would be propagated automatically as well.

> 2. What is the best location for the new supplemental binaries (tst_checkpoint_wait,
> tst_checkpoint_wake)? tools/apicmds/ltpapicmd.c or separate source files in
> testcases/lib/ (similar to tst_sleep)?

I would go for separate binary in testcases/lib/ rather than adding to
the ltpapicmd.c which should really be removed at some point in future,
once there are no users for the binary tst_resm.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [RFC PATCH 2/2] An example of usage of tst_checkpoint shell wrappers
  2016-06-01 14:34 ` [LTP] [RFC PATCH 2/2] An example of usage of " Stanislav Kholmanskikh
@ 2016-06-01 15:12   ` Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2016-06-01 15:12 UTC (permalink / raw)
  To: ltp

Hi!
I really like how we can mix the checkpoints between the C and shell
source now ;).

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [RFC] shell wrappers for tst_checkpoint
  2016-06-01 14:34 [LTP] [RFC] shell wrappers for tst_checkpoint Stanislav Kholmanskikh
                   ` (2 preceding siblings ...)
  2016-06-01 15:03 ` [LTP] [RFC] shell wrappers for tst_checkpoint Cyril Hrubis
@ 2016-06-02  7:58 ` Jan Stancek
  2016-06-02  8:20   ` Stanislav Kholmanskikh
  3 siblings, 1 reply; 9+ messages in thread
From: Jan Stancek @ 2016-06-02  7:58 UTC (permalink / raw)
  To: ltp





----- Original Message -----
> From: "Stanislav Kholmanskikh" <stanislav.kholmanskikh@oracle.com>
> To: ltp@lists.linux.it
> Cc: "vasily isaenko" <vasily.isaenko@oracle.com>
> Sent: Wednesday, 1 June, 2016 4:34:51 PM
> Subject: [LTP] [RFC] shell wrappers for tst_checkpoint
> 
> Hi!
> 
> There is a need to use the tst_checkpoint interface from shell, but
> we don't have wrappers for it (yet).
> 
> Patch 1 of the series contains one possible implementation for that,
> patch 2 - an example of usage in the context of the memcg_functional test
> case.
> 
> I'd like to get some feedback from LTP users.

If we don't plan to support oldlib, we should document that shell
checkpoints will work only with newlib C testcases, since oldlib
currently doesn't use LTP_IPC_PATH and file has different layout
(there is no results struct).

> 
> My primary concern is about two issues:
> 
> 1. The new test API for C is cool and takes the responsibility on
>    maintaining the infrastructure for tst_checkpoint. However, I couldn't
>    find
>    a way to implement something similar in shell, so I switched back to using
>    two separate functions for that - TST_CHECKPOINT_SETUP,
>    TST_CHECKPOINT_CLEANUP.
> 
>    There may be a better way...
> 
> 2. What is the best location for the new supplemental binaries
> (tst_checkpoint_wait,
> tst_checkpoint_wake)? tools/apicmds/ltpapicmd.c or separate source files in
> testcases/lib/ (similar to tst_sleep)?
> 
> Thanks.
> 
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [RFC] shell wrappers for tst_checkpoint
  2016-06-02  7:58 ` Jan Stancek
@ 2016-06-02  8:20   ` Stanislav Kholmanskikh
  0 siblings, 0 replies; 9+ messages in thread
From: Stanislav Kholmanskikh @ 2016-06-02  8:20 UTC (permalink / raw)
  To: ltp



On 06/02/2016 10:58 AM, Jan Stancek wrote:
>
>
>
>
> ----- Original Message -----
>> From: "Stanislav Kholmanskikh" <stanislav.kholmanskikh@oracle.com>
>> To: ltp@lists.linux.it
>> Cc: "vasily isaenko" <vasily.isaenko@oracle.com>
>> Sent: Wednesday, 1 June, 2016 4:34:51 PM
>> Subject: [LTP] [RFC] shell wrappers for tst_checkpoint
>>
>> Hi!
>>
>> There is a need to use the tst_checkpoint interface from shell, but
>> we don't have wrappers for it (yet).
>>
>> Patch 1 of the series contains one possible implementation for that,
>> patch 2 - an example of usage in the context of the memcg_functional test
>> case.
>>
>> I'd like to get some feedback from LTP users.
>
> If we don't plan to support oldlib, we should document that shell
> checkpoints will work only with newlib C testcases, since oldlib
> currently doesn't use LTP_IPC_PATH and file has different layout
> (there is no results struct).

I'd better remove the old checkpoint api from LTP. There are ~20 C test 
cases using TST_CHECKPOINT_INIT(). It should be doable to convert them 
to using the new api, since it's likely that they are not "legacy" and 
don't require additional cleanup. :)

Per my understanding, all new C test cases are expected to be written 
with the new api, so the only downside of this approach is that removing 
TST_CHECKPOINT_INIT() may require more time.


>
>>
>> My primary concern is about two issues:
>>
>> 1. The new test API for C is cool and takes the responsibility on
>>     maintaining the infrastructure for tst_checkpoint. However, I couldn't
>>     find
>>     a way to implement something similar in shell, so I switched back to using
>>     two separate functions for that - TST_CHECKPOINT_SETUP,
>>     TST_CHECKPOINT_CLEANUP.
>>
>>     There may be a better way...
>>
>> 2. What is the best location for the new supplemental binaries
>> (tst_checkpoint_wait,
>> tst_checkpoint_wake)? tools/apicmds/ltpapicmd.c or separate source files in
>> testcases/lib/ (similar to tst_sleep)?
>>
>> Thanks.
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
>>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [RFC] shell wrappers for tst_checkpoint
  2016-06-01 15:03 ` [LTP] [RFC] shell wrappers for tst_checkpoint Cyril Hrubis
@ 2016-06-02 14:58   ` Stanislav Kholmanskikh
  2016-06-06  8:40     ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Stanislav Kholmanskikh @ 2016-06-02 14:58 UTC (permalink / raw)
  To: ltp

Hi!

On 06/01/2016 06:03 PM, Cyril Hrubis wrote:
> Hi!
>> There is a need to use the tst_checkpoint interface from shell, but
>> we don't have wrappers for it (yet).
>>
>> Patch 1 of the series contains one possible implementation for that,
>> patch 2 - an example of usage in the context of the memcg_functional test case.
>>
>> I'd like to get some feedback from LTP users.
>>
>> My primary concern is about two issues:
>>
>> 1. The new test API for C is cool and takes the responsibility on
>>     maintaining the infrastructure for tst_checkpoint. However, I couldn't find
>>     a way to implement something similar in shell, so I switched back to using
>>     two separate functions for that - TST_CHECKPOINT_SETUP, TST_CHECKPOINT_CLEANUP.
>>
>>     There may be a better way...
>
> Well we can always put the cleanup into the tst_exit() which is executed
> both on clean and unclean exit (tst_brkm). And the setup could be done
> right after the checks for TCID and TST_TOTAL. Both supposedly if
> something as TST_NEEDS_CHECKPOINTS=1 has been set before sourcing
> test.sh.
>
> Also nothing stops us from bringing the shell API closer to what we have
> for C :).
>
> We would have to source the test library script after we had defined all
> the setup() cleanup() and test() functions and after setting the
> corresponding TST_ID=foo, TST_NEEDS_CHECKPOINTS=1, etc. But as far as I
> can tell it seems doable.

Could, you, please, have a look at the attached series. I suppose it 
addresses your proposal. In particular, the changes are:
  * tst_checkpoint_* binaries were moved to testcases/lib/
  * logic from TST_CHECKPOINT_CLEANUP was moved to tst_exit()
  * logic from TST_CHECKPOINT_SETUP was moved right into tst_test.sh 
(now it depends on TST_NEEDS_CHECKPOINTS flag)

Existent test cases should not be affected by this change.

If checkpoints are needed, TST_NEEDS_CHECKPOINTS must be defined before 
'.test.sh'. I think this fact could be documented.

>
> And it would be really cool if we managed to use the shared memory for
> test results as well so that result from child processes (subshells)
> would be propagated automatically as well.

Yes, but may this be addressed sometimes later :)


>
>> 2. What is the best location for the new supplemental binaries (tst_checkpoint_wait,
>> tst_checkpoint_wake)? tools/apicmds/ltpapicmd.c or separate source files in
>> testcases/lib/ (similar to tst_sleep)?
>
> I would go for separate binary in testcases/lib/ rather than adding to
> the ltpapicmd.c which should really be removed at some point in future,
> once there are no users for the binary tst_resm.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-shell-wrapper-for-tst_checkpoint.patch
Type: text/x-patch
Size: 4897 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160602/7b15e917/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-an-example-of-usage.patch
Type: text/x-patch
Size: 4677 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160602/7b15e917/attachment-0001.bin>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [RFC] shell wrappers for tst_checkpoint
  2016-06-02 14:58   ` Stanislav Kholmanskikh
@ 2016-06-06  8:40     ` Cyril Hrubis
  0 siblings, 0 replies; 9+ messages in thread
From: Cyril Hrubis @ 2016-06-06  8:40 UTC (permalink / raw)
  To: ltp

Hi!
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> index 70345e5..00eeeae 100644
> --- a/testcases/lib/test.sh
> +++ b/testcases/lib/test.sh
> @@ -100,6 +100,10 @@ tst_exit()
>  		$TST_CLEANUP
>  	fi
>  
> +	if [ -n "$LTP_IPC_PATH" -a -f "$LTP_IPC_PATH" ]; then
> +		rm -f "$LTP_IPC_PATH"
> +	fi
> +
>  	# Mask out TINFO
>  	exit $((LTP_RET_VAL & ~16))
>  }
> @@ -374,6 +378,16 @@ tst_module_exists()
>  	tst_brkm TCONF "Failed to find module '$mod_name'"
>  }
>  
> +TST_CHECKPOINT_WAIT()
> +{
> +	ROD tst_checkpoint_wait "$1" 10000
> +}
> +
> +TST_CHECKPOINT_WAKE()
> +{
> +	ROD tst_checkpoint_wake "$1" 10000
> +}

Given that we have wrappers for the checkpoint programs anyway, we can
build just one binary called tst_checkpoint and pass the wait/wake as
first parameter. That way we can spare us the special rules in Makefile
and ifdefs in the checkpoint C source.

>  # Check that test name is set
>  if [ -z "$TCID" ]; then
>  	tst_brkm TBROK "TCID is not defined"
> @@ -393,3 +407,16 @@ if [ -z "$LTPROOT" ]; then
>  else
>  	export LTP_DATAROOT="$LTPROOT/testcases/data/$TCID"
>  fi
> +
> +if [ "$TST_NEEDS_CHECKPOINTS" = "1" ]; then
> +	LTP_IPC_PATH="/dev/shm/ltp_$$"

We may also include the $TCID in the filename, since that would make
identifying which tests possibly failed to cleanup easier...

> +	LTP_IPC_SIZE=$(getconf PAGESIZE)
> +	if [ $? -ne 0 ]; then
> +		tst_brkm TBROK "getconf PAGESIZE failed"
> +	fi
> +
> +	ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$LTP_IPC_SIZE" count=1
> +	ROD_SILENT chmod 600 "$LTP_IPC_PATH"
> +	export LTP_IPC_PATH
> +fi

Otherwise this looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-06  8:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-01 14:34 [LTP] [RFC] shell wrappers for tst_checkpoint Stanislav Kholmanskikh
2016-06-01 14:34 ` [LTP] [RFC PATCH 1/2] a draft for tst_checkpoint shell wrappers Stanislav Kholmanskikh
2016-06-01 14:34 ` [LTP] [RFC PATCH 2/2] An example of usage of " Stanislav Kholmanskikh
2016-06-01 15:12   ` Cyril Hrubis
2016-06-01 15:03 ` [LTP] [RFC] shell wrappers for tst_checkpoint Cyril Hrubis
2016-06-02 14:58   ` Stanislav Kholmanskikh
2016-06-06  8:40     ` Cyril Hrubis
2016-06-02  7:58 ` Jan Stancek
2016-06-02  8:20   ` Stanislav Kholmanskikh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox