Skip to contentSkip to conversation

cpu_hotplug: Add executable file's path

PATCH New zhaogongyi 2 participants 2 messages Feb 23, 2021

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

PATCH 1/1 cpu_hotplug: Add executable file's path

Hi Xu,

Thanks for your review!

In many embedded system, before running testcases we need type in the following lines:

    #export LTPROOT=/opt/ltp
    #export PATH="$PATH:$LTPROOT/testcases/bin"
    # cpuhotplug02.sh -c 1 -l 1

It is not convenient for running test after every login.

Can we change " cpuhotplug_do_disk_write_loop> /dev/null 2>&1&" to " {BIN}/cpuhotplug_do_disk_write_loop> /dev/null 2>&1&" and set BIN at init phase(for example in test.sh)

if [ -e $LTPROOT/testcases/bin ];then
BIN=$LTPROOT/testcases/bin
else

	BIN=./

fi

So, we can run test like:

    #cd INSTALL_DIR
	#./cpuhotplug02.sh -c 1 -l 1

It is more efficient for testing in embedded system and is more friendly for one who don't know the file cpuhotplug02.sh depending on cpuhotplug_do_disk_write_loop.

And what do u think about this?

Quoted 184 lines

Hi gongyi

Quoted 3 lines

Hi Xu,

In many cases, we set a default path for executable file would be more

friendly for user?
I think it is friendly to user. LTP has friendly documentation to mention this?

In user-guide.txt
https://github.com/linux-test-project/ltp/blob/master/doc/user-guide.txt

| 'LTPROOT' | Prefix for installed LTP, the default is
'/opt/ltp'

| 'PATH' | It's required to addjust path:

                           `PATH="$PATH:$LTPROOT/testcases/bin"`

In README.md
Each test case has its own executable or script, these can be executed directly $ testcases/bin/abort01 Some have arguments

$ testcases/bin/fork13 -i 37 The vast majority of test cases accept the -h
(help) switch $ testcases/bin/ioctl01 -h Many require certain environment
variables to be set $ LTPROOT=/opt/ltp
PATH="$PATH:$LTPROOT/testcases/bin" testcases/bin/wc01.sh Most
commonly, the path variable needs to be set and also LTPROOT, but there
are a number of other variables, runltp usually sets these for you.
Note that all shell scripts need the PATH to be set. However this is not
limited to shell scripts, many C based tests need environment variables as
well.

Also for some special case, like prctl06.c, we can use resource_files to copy some other execute file to some place.

Quoted 2 lines

And in these cases, it is better to judge return value behind running

cpuhotplug_do_spin_loop since the error info has been redirected to /dev/null?
the cpuhotplug_do_spin_loop function only does a spin loop, IMO, it will not fail and here just make the output silent.

Best Regards
Yang Xu

Quoted 19 lines
Quoted 19 lines

Hi Gongyi

Quoted 5 lines

When env PATH is not include current path, run cpuhotplug_do_disk_write_loop/ cpuhotplug_do_spin_loop/cpuhotplug_do_kcompile_loop/ cpuhotplug_report_proc_interrupts will fail.

This patch is useless.

For shell-script case, usually, runltp will set environment variables. or, you need to set environment variables yourself if not want to use runltp(more info see[1]).
For cpuhotplug02 case, we can run as below:
#export LTPROOT=/opt/ltp
#export PATH="$PATH:$LTPROOT/testcases/bin" #cpuhotplug02.sh -c 1 -l 1

Quoted 6 lines
Quoted 6 lines

[1]https://github.com/linux-test-project/ltp/blob/master/README.md

Best Regards
Yang Xu

Quoted 2 lines

For those:

testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh

Quoted 1 line
Quoted 1 line
Quoted 1 line

testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh

Quoted 1 line
Quoted 1 line
Quoted 1 line

testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh

Quoted 1 line
Quoted 1 line
Quoted 1 line

testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

---
.../kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh

| 4

Quoted 2 lines
Quoted 2 lines

++--

Quoted 1 line

.../kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh

| 2

Quoted 2 lines
Quoted 2 lines
+-
>    .../kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh

| 2

Quoted 2 lines
Quoted 2 lines
+-
>    .../kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh

| 2

Quoted 8 lines
Quoted 8 lines
+-
>    4 files changed, 5 insertions(+), 5 deletions(-)
Quoted 6 lines

diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh index 1ba937cc7..b1c8a9b97 100755
---

a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh

Quoted 11 lines
Quoted 11 lines
Quoted 1 line

+++

b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug01.sh

Review cpu_states=$(get_all_cpu_states) · line 143

Quoted 9 lines
(quoted diff) +1 -1
@@ -137,7 +137,7 @@ cpu_states=$(get_all_cpu_states)
   CPU_COUNT=0
 
   # Start up a process that writes to disk; keep track of its PID
-cpuhotplug_do_disk_write_loop>   /dev/null 2>&1&
+./cpuhotplug_do_disk_write_loop>   /dev/null 2>&1&
   WRL_ID=$!
 
   until [ $LOOP_COUNT -gt $HOTPLUG01_LOOPS ] @@ -181,7

+181,7

Quoted 8 lines
Quoted 8 lines

@@ do

Quoted 7 lines

# Print out a report showing the changes in IRQs echo
echo

(quoted diff) +1 -1
-	cpuhotplug_report_proc_interrupts "$IRQ_START" "$IRQ_END"
+	./cpuhotplug_report_proc_interrupts "$IRQ_START" "$IRQ_END"
   	echo
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

sleep $TM_DLY
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh index 792f8cd73..f8a1395c1 100755
---

a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh

Quoted 10 lines
Quoted 10 lines
Quoted 1 line

+++

b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug02.sh

Quoted 8 lines
(quoted diff) +1 -1
@@ -77,7 +77,7 @@ fi
   TST_CLEANUP=do_clean
 
   # Start up a process that just uses CPU cycles
-cpuhotplug_do_spin_loop>   /dev/null&
+./cpuhotplug_do_spin_loop>   /dev/null&
   SPIN_LOOP_PID=$!
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -0
   sleep 5

diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh index 9ea49f0e1..75a05a3c9 100755
---

a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

+++

b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug03.sh

Review until [ $LOOP_COUNT -gt

Quoted 1 line
(quoted diff) +0 -0
@@ -102,7 +102,7 @@ until [ $LOOP_COUNT -gt

$HOTPLUG03_LOOPS ]; do

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +1 -1
   	# so we can kill them later.
   	number_of_procs=$((cpus_num*2))
   	until [ $number_of_procs -eq 0 ]; do
-		cpuhotplug_do_spin_loop>   /dev/null 2>&1&
+		./cpuhotplug_do_spin_loop>   /dev/null 2>&1&
Quoted 8 lines
Quoted 8 lines
(quoted diff) +0 -0
   		echo $!>>   /var/run/hotplug4_$$.pid
   		number_of_procs=$((number_of_procs-1))
   	done

diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh index 278304618..e8ab78e8c 100755
---

a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh

Quoted 22 lines
Quoted 10 lines
Quoted 1 line

+++

b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug07.sh

Quoted 8 lines
(quoted diff) +1 -1
@@ -81,7 +81,7 @@ fi
 
   TST_CLEANUP=do_clean
 
-cpuhotplug_do_kcompile_loop $KERNEL_DIR>   /dev/null 2>&1&
+./cpuhotplug_do_kcompile_loop $KERNEL_DIR>   /dev/null 2>&1&
   KCOMPILE_LOOP_PID=$!
 
Quoted 7 lines
Quoted 5 lines
(quoted diff) +0 -1
   tst_resm TINFO "initial CPU affinity for kernel compile is: \
--

2.17.1

.

#1 lore raw

PATCH 1/1 cpu_hotplug: Add executable file's path

Hi!

Quoted 9 lines

Thanks for your review!

In many embedded system, before running testcases we need type in the following lines:

    #export LTPROOT=/opt/ltp
    #export PATH="$PATH:$LTPROOT/testcases/bin"
    # cpuhotplug02.sh -c 1 -l 1

It is not convenient for running test after every login.

This is what you have to do if you are not using the runltp script and that's it. We will not add workarounds into our testcases.

Also nobody stops you from writing a short wrapper script such as:

$ cat run_test.sh

#!/bin/sh

export LTPROOT=/opt/ltp
export PATH="$PATH:$LTPROOT/testcases/bin"

$@

And then using it as:

./run_test.sh cpuhotplug02.sh -c 1 -l 1

Signature · 2 lines
Cyril Hrubis
[email protected]