Skip to contentSkip to conversation

New API: Rename LTP_IPC_PATH -> TST_IPC_PATH

PATCH New Petr Vorel 3 participants 15 messages Aug 25, 2021 Library code

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

cover New API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Petr Vorel (3):
lib: Move IPC_ENV_VAR definition into header
C API: Rename LTP_IPC_PATH -> TST_IPC_PATH
shell API: Rename LTP_IPC_PATH -> TST_IPC_PATH

 doc/c-test-api.txt                          |  2 +-
 include/tst_test.h                          |  4 +++-
 lib/tst_test.c                              |  2 --
 testcases/kernel/syscalls/execle/execle01.c |  2 --
 testcases/kernel/syscalls/execve/execve01.c |  2 --
 testcases/kernel/syscalls/prctl/prctl06.h   |  1 -
 testcases/lib/tst_test.sh                   | 12 ++++++------
 7 files changed, 10 insertions(+), 15 deletions(-)
Signature · 1 line
2.32.0
author
#1 lore raw

PATCH 1/3 lib: Move IPC_ENV_VAR definition into header

thus it can be used in tests instead of duplicate definition.

---
 include/tst_test.h                          | 2 ++
 lib/tst_test.c                              | 2 --
 testcases/kernel/syscalls/execle/execle01.c | 2 --
 testcases/kernel/syscalls/execve/execve01.c | 2 --
 testcases/kernel/syscalls/prctl/prctl06.h   | 1 -
 5 files changed, 2 insertions(+), 7 deletions(-)
include/tst_test.h +2 -0
index ce4e007cf..27ebed94e 100644
@@ -275,6 +275,8 @@ struct tst_test {
 void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
                     __attribute__ ((noreturn));
 
+#define IPC_ENV_VAR "LTP_IPC_PATH"
+
 /*
  * Does library initialization for child processes started by exec()
  *
lib/tst_test.c +0 -2
index 1bdea769a..b61aa8b03 100644
@@ -71,8 +71,6 @@ static int ipc_fd;
 extern void *tst_futexes;
 extern unsigned int tst_max_futexes;
 
-#define IPC_ENV_VAR "LTP_IPC_PATH"
-
 static char ipc_path[1064];
 const char *tst_ipc_path = ipc_path;
 
testcases/kernel/syscalls/execle/execle01.c +0 -2
index f10813cca..917dc892f 100644
@@ -16,8 +16,6 @@
 
 #include "tst_test.h"
 
-#define IPC_ENV_VAR "LTP_IPC_PATH"
-
 static void verify_execle(void)
 {
 	pid_t pid;
testcases/kernel/syscalls/execve/execve01.c +0 -2
index 9331c9480..2b12c7666 100644
@@ -17,8 +17,6 @@
 
 #include "tst_test.h"
 
-#define IPC_ENV_VAR "LTP_IPC_PATH"
-
 static void verify_execve(void)
 {
 	pid_t pid;
testcases/kernel/syscalls/prctl/prctl06.h +0 -1
index 227ce3006..510fefa60 100644
@@ -17,7 +17,6 @@
 #include "tst_test.h"
 
 #define PROC_STATUS        "/proc/self/status"
-#define IPC_ENV_VAR        "LTP_IPC_PATH"
 #define MNTPOINT           "mntpoint"
 #define TESTBIN            "prctl06_execve"
 #define TEST_REL_BIN_DIR   MNTPOINT"/"
Signature · 1 line
2.32.0
author
#3 lore raw

PATCH 1/3 lib: Move IPC_ENV_VAR definition into header

Hi Cyril,

Quoted 2 lines

Hi!
This one is obviously okay.

Thanks, merged.

Kind regards,
Petr

author
#4 lore raw

PATCH 2/3 C API: Rename LTP_IPC_PATH -> TST_IPC_PATH

In reply to Petr Vorel

To follow the conventions in the new API.

Update also C API docs.

NOTE: IPC is not supported in the legacy API.

---
 doc/c-test-api.txt | 2 +-
 include/tst_test.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
doc/c-test-api.txt +1 -1
index 3127018a4..a092bc572 100644
@@ -654,7 +654,7 @@ int main(void)
 
 The 'tst_res()' function can be also used from binaries started by 'exec()',
 the parent test process has to set the '.child_needs_reinit' flag so that the
-library prepares for it and has to make sure the 'LTP_IPC_PATH' environment
+library prepares for it and has to make sure the 'TST_IPC_PATH' environment
 variable is passed down, then the very fist thing the program has to call in
 'main()' is 'tst_reinit()' that sets up the IPC.
 
include/tst_test.h +2 -2
index 27ebed94e..4c0749865 100644
@@ -275,12 +275,12 @@ struct tst_test {
 void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
                     __attribute__ ((noreturn));
 
-#define IPC_ENV_VAR "LTP_IPC_PATH"
+#define IPC_ENV_VAR "TST_IPC_PATH"
 
 /*
  * Does library initialization for child processes started by exec()
  *
- * The LTP_IPC_PATH variable must be passed to the program environment.
+ * The TST_IPC_PATH variable must be passed to the program environment.
  */
 void tst_reinit(void);
 
Signature · 1 line
2.32.0
#5 lore raw

PATCH 2/3 C API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi Petr,

Quoted 5 lines · Petr Vorel

To follow the conventions in the new API.

Update also C API docs.

NOTE: IPC is not supported in the legacy API.

Do you mean legacy c api here? It is supported. See old_checkpoints.h.

Joerg

author
#6 lore raw

PATCH 2/3 C API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi Joerg,

...

Quoted 2 lines
Quoted 1 line

NOTE: IPC is not supported in the legacy API.

Do you mean legacy c api here? It is supported. See old_checkpoints.h.

Ah good, point, thanks! (include/old/old_checkpoint.h). But if I look correctly, LTP_IPC_PATH is not used there, right?

Kind regards,
Petr

#7 lore raw

PATCH 2/3 C API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi Petr,

Quoted 7 lines · Petr Vorel

Hi Joerg,

...

Quoted 2 lines
Quoted 1 line

NOTE: IPC is not supported in the legacy API.

Do you mean legacy c api here? It is supported. See old_checkpoints.h.

Ah good, point, thanks! (include/old/old_checkpoint.h). But if I look correctly, LTP_IPC_PATH is not used there, right?

It uses the same code as the new implementation (tst_checkpoint.c). So no changes necessary,
but the commit message is misleading.

Joerg

author
#8 lore raw

PATCH 3/3 shell API: Rename LTP_IPC_PATH -> TST_IPC_PATH

In reply to Petr Vorel

To follow the conventions in the new API.

Keep the old name in the legacy API.

---
 testcases/lib/tst_test.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
testcases/lib/tst_test.sh +6 -6
index acf62c9ac..b68fae0b8 100644
@@ -49,8 +49,8 @@ _tst_do_exit()
 		[ "$TST_TMPDIR_RHOST" = 1 ] && tst_cleanup_rhost
 	fi
 
-	if [ -n "$TST_NEEDS_CHECKPOINTS" -a -f "$LTP_IPC_PATH" ]; then
-		rm $LTP_IPC_PATH
+	if [ -n "$TST_NEEDS_CHECKPOINTS" -a -f "$TST_IPC_PATH" ]; then
+		rm $TST_IPC_PATH
 	fi
 
 	_tst_cleanup_timer
@@ -582,14 +582,14 @@ _tst_init_checkpoints()
 {
 	local pagesize
 
-	LTP_IPC_PATH="/dev/shm/ltp_${TST_ID}_$$"
+	TST_IPC_PATH="/dev/shm/ltp_${TST_ID}_$$"
 	pagesize=$(tst_getconf PAGESIZE)
 	if [ $? -ne 0 ]; then
 		tst_brk TBROK "tst_getconf PAGESIZE failed"
 	fi
-	ROD_SILENT dd if=/dev/zero of="$LTP_IPC_PATH" bs="$pagesize" count=1
-	ROD_SILENT chmod 600 "$LTP_IPC_PATH"
-	export LTP_IPC_PATH
+	ROD_SILENT dd if=/dev/zero of="$TST_IPC_PATH" bs="$pagesize" count=1
+	ROD_SILENT chmod 600 "$TST_IPC_PATH"
+	export TST_IPC_PATH
 }
 
 tst_run()
Signature · 1 line
2.32.0
#9 lore raw

PATCH 3/3 shell API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi,

Quoted 3 lines · Petr Vorel

To follow the conventions in the new API.

Keep the old name in the legacy API.

That doesn't make sense. If you update the variable name in the c api, you also have to update the old shell api (i.e. test.sh).
Or maybe even remove the code from the old shell api completely. As far as I see there are no users of the checkpoint api anymore. Both tests (cn_pec and memcfg/functional) were rewritten. It is probably safe to just drop the old api?

Joerg

author
#10 lore raw

PATCH 3/3 shell API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi Joerg,

Quoted 3 lines
Quoted 1 line

Keep the old name in the legacy API.

That doesn't make sense. If you update the variable name in the c api, you also have to update the old shell api (i.e. test.sh).

Ah, shell API implementation obviously depends on C API. Thanks for info.

Quoted 4 lines

Or maybe even remove the code from the old shell api completely. As far as I see there are no users of the checkpoint api anymore.
Both tests (cn_pec and memcfg/functional) were rewritten. It is probably safe to just drop the old api?

I'll check it, if it's really not used in the legacy API, I'd be also for removing it.

Kind regards,
Petr

#11 lore raw

cover New API: Rename LTP_IPC_PATH -> TST_IPC_PATH

In reply to Petr Vorel

Hi!

Quoted 4 lines

Petr Vorel (3):
lib: Move IPC_ENV_VAR definition into header
C API: Rename LTP_IPC_PATH -> TST_IPC_PATH
shell API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Is this really a good idea?

As it is it's pretty clear where the environment variable comes from, if we rename it to TST_IPC_PATH it's not obvious that this has been exported by LTP test.

Generally things that are visible on the running system tends to be prefixed with LTP_ or ltp_ rather than TST_ or tst_...

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#12 lore raw

cover New API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Quoted 11 lines

Hi!

Quoted 4 lines

Petr Vorel (3):
lib: Move IPC_ENV_VAR definition into header
C API: Rename LTP_IPC_PATH -> TST_IPC_PATH
shell API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Is this really a good idea?

As it is it's pretty clear where the environment variable comes from, if we rename it to TST_IPC_PATH it's not obvious that this has been exported by LTP test.

I was thinking about it as well (just forget to write that into cover letter).

Quoted 2 lines

Generally things that are visible on the running system tends to be prefixed with LTP_ or ltp_ rather than TST_ or tst_...

Sure. I just thought that LTP_ is for variables which are expected to be set by user. But let's keep the old name. How about the first commit (cleanup)?

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/wiki/User-Guidelines

#13 lore raw

cover New API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi!

Quoted 9 lines
Quoted 3 lines

As it is it's pretty clear where the environment variable comes from, if we rename it to TST_IPC_PATH it's not obvious that this has been exported by LTP test.

I was thinking about it as well (just forget to write that into cover letter).

Quoted 2 lines

Generally things that are visible on the running system tends to be prefixed with LTP_ or ltp_ rather than TST_ or tst_...

Sure. I just thought that LTP_ is for variables which are expected to be set by user. But let's keep the old name. How about the first commit (cleanup)?

There is no such rule I guess.

It has been case by case, for instance we do have KCONFIG_PATH which we agreed on with the testing community to be a canonical variable name that is shared between different frameworks.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#14 lore raw

cover New API: Rename LTP_IPC_PATH -> TST_IPC_PATH

Hi Cyril, Joerg,

Quoted 8 lines

Hi!

Quoted 7 lines
Quoted 3 lines

As it is it's pretty clear where the environment variable comes from, if we rename it to TST_IPC_PATH it's not obvious that this has been exported by LTP test.

I was thinking about it as well (just forget to write that into cover letter).

Quoted 2 lines

Generally things that are visible on the running system tends to be prefixed with LTP_ or ltp_ rather than TST_ or tst_...

Quoted 8 lines
Quoted 2 lines

Sure. I just thought that LTP_ is for variables which are expected to be set by user. But let's keep the old name. How about the first commit (cleanup)?

There is no such rule I guess.

It has been case by case, for instance we do have KCONFIG_PATH which we agreed on with the testing community to be a canonical variable name that is shared between different frameworks.

Ah, thanks for info. Obviously there cannot be rules for everything :). Thanks both for your time.

Kind regards,
Petr