Skip to contentSkip to conversation

open_posix_testsuite: Fix compilation issues

PATCH Superseded Zou Wei 5 participants 7 messages Mar 17, 2020 – Mar 19, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zou Wei

author
#0 lore raw

PATCH 1/1 open_posix_testsuite: Fix compilation issues

Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS
2. Update makefile and locate-test script

---
 testcases/open_posix_testsuite/LDFLAGS             | 1 +
 testcases/open_posix_testsuite/functional/Makefile | 2 +-
 testcases/open_posix_testsuite/scripts/locate-test | 2 +-
 testcases/open_posix_testsuite/stress/Makefile     | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)
testcases/open_posix_testsuite/LDFLAGS +1 -0
index e69de29..6c112d3 100644
@@ -0,0 +1 @@
+-lpthread -lrt -lm
testcases/open_posix_testsuite/functional/Makefile +1 -1
index 3b22c89..50e03aa 100644
@@ -5,7 +5,7 @@
 #
 
 all clean install test:
-	@for dir in `ls -d */Makefile 2>/dev/null | sed -e 's,/Makefile$$,,g'`; do \
+	@for dir in `find . -name *Makefile | egrep -v '^./Makefile' | sed -e 's,/Makefile$$,,g'`; do \
 		$(MAKE) -C $$dir $@;						   \
 	done
 
testcases/open_posix_testsuite/scripts/locate-test +1 -1
index 27f0bb5..e4ef994 100755
@@ -92,7 +92,7 @@ runnable)
 	# waltz down the tools directory and try and build t0 (which doesn't
 	# make sense as it's a tool, not a test). Better criterion needs to
 	# be established for this file.
-	find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools'
+	find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9a-z].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools' | grep -v 'testfrmw.c$'
 	find "$WHERE/functional" -type f -name '*.c'
 	;;
 test-tools)
testcases/open_posix_testsuite/stress/Makefile +1 -1
index b09527f..d6872a9 100644
@@ -5,7 +5,7 @@
 #
 
 all clean install test:
-	@for dir in `ls -d */Makefile 2>/dev/null | sed -e 's,/Makefile$$,,g'`; do \
+	@for dir in `find . -name *Makefile | egrep -v '^./Makefile' | sed -e 's,/Makefile$$,,g'`; do \
 		$(MAKE) -C $$dir $@;						  \
 	done
 

--
2.6.2

#1 lore raw

PATCH 1/1 open_posix_testsuite: Fix compilation issues

Quoted 6 lines · Zou Wei

Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS
2. Update makefile and locate-test script

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200317/4027ca28/attachment.htm>
#2 lore raw

PATCH 1/1 open_posix_testsuite: Fix compilation issues

In reply to Zou Wei

Hi Zou

Quoted 2 lines

Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS

See ltp/openposix/build[1] documention, as below:

----------------------------
If you need to pass in any header locations, preprocessor definitions, etc,
set the value via CFLAGS.
- If you need to pass in any libraries for linking, set the value via LDLIBS.
- If you need to pass any other values to the linker, set the value via LDFLAGS.
----------------------------

I guess we should use LDLIBS.

Also, do we must specify three '-lpthread -lrt -lm' configs into this? Some case only needs one lib, such as functional/timers/timers . I guess we can only add LDLIBS in case directory such as functional/timers/timers because generate-makefiles.sh will load libs from current directory.

ps: I will test this patch by using travis.

[1]https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/BUILD

Best Regards
Yang Xu

Quoted 59 lines

2. Update makefile and locate-test script

---
  testcases/open_posix_testsuite/LDFLAGS             | 1 +
  testcases/open_posix_testsuite/functional/Makefile | 2 +-
  testcases/open_posix_testsuite/scripts/locate-test | 2 +-
  testcases/open_posix_testsuite/stress/Makefile     | 2 +-
  4 files changed, 4 insertions(+), 3 deletions(-)
testcases/open_posix_testsuite/LDFLAGS +1 -0
index e69de29..6c112d3 100644
@@ -0,0 +1 @@
+-lpthread -lrt -lm
testcases/open_posix_testsuite/functional/Makefile +1 -1
index 3b22c89..50e03aa 100644
@@ -5,7 +5,7 @@
  #
 
  all clean install test:
-	@for dir in `ls -d */Makefile 2>/dev/null | sed -e 's,/Makefile$$,,g'`; do \
+	@for dir in `find . -name *Makefile | egrep -v '^./Makefile' | sed -e 's,/Makefile$$,,g'`; do \
  		$(MAKE) -C $$dir $@;						   \
  	done
 
testcases/open_posix_testsuite/scripts/locate-test +1 -1
index 27f0bb5..e4ef994 100755
@@ -92,7 +92,7 @@ runnable)
  	# waltz down the tools directory and try and build t0 (which doesn't
  	# make sense as it's a tool, not a test). Better criterion needs to
  	# be established for this file.
-	find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools'
+	find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9a-z].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools' | grep -v 'testfrmw.c$'
  	find "$WHERE/functional" -type f -name '*.c'
  	;;
  test-tools)
testcases/open_posix_testsuite/stress/Makefile +1 -2
index b09527f..d6872a9 100644
@@ -5,7 +5,7 @@
  #
 
  all clean install test:
-	@for dir in `ls -d */Makefile 2>/dev/null | sed -e 's,/Makefile$$,,g'`; do \
+	@for dir in `find . -name *Makefile | egrep -v '^./Makefile' | sed -e 's,/Makefile$$,,g'`; do \
  		$(MAKE) -C $$dir $@;						  \
  	done
 
--

2.6.2

#3 lore raw

PATCH 1/1 open_posix_testsuite: Fix compilation issues

Quoted 16 lines · Yang Xu

Hi Zou

Quoted 2 lines

Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS

See ltp/openposix/build[1] documention, as below:

----------------------------
If you need to pass in any header locations, preprocessor definitions, etc,
set the value via CFLAGS.
- If you need to pass in any libraries for linking, set the value via LDLIBS.
- If you need to pass any other values to the linker, set the value via LDFLAGS.
----------------------------

Quoted 2 lines

I guess we should use LDLIBS.

Xu is right, I misread these two words(LDLIBS vs LDFLAGS) during my reviewing.

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200317/25d997ac/attachment.htm>
#4 lore raw

PATCH 1/1 open_posix_testsuite: Fix compilation issues

In reply to Zou Wei

NAK.

This should use LDLIBS, as others have pointed out, not LDFLAGS.

This also spams these libraries on all tests, instead of the ones that need it.

I can see there?s a desire to build/make open posix testsuite by default. I?ll look into making it so soon because the current model is a PITA to maintain and doesn?t integrate well into CI/CD.

Cheers,
-Enji

Quoted 65 lines · Zou Wei

?Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS
2. Update makefile and locate-test script

---

testcases/open_posix_testsuite/LDFLAGS             | 1 +
testcases/open_posix_testsuite/functional/Makefile | 2 +-
testcases/open_posix_testsuite/scripts/locate-test | 2 +-
testcases/open_posix_testsuite/stress/Makefile     | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)
testcases/open_posix_testsuite/LDFLAGS +1 -0
index e69de29..6c112d3 100644
@@ -0,0 +1 @@
+-lpthread -lrt -lm
testcases/open_posix_testsuite/functional/Makefile +0 -0
index 3b22c89..50e03aa 100644
@@ -5,7 +5,7 @@
 #
 

all clean install test:

testcases/open_posix_testsuite/functional/Makefile +1 -1
-    @for dir in `ls -d */Makefile 2>/dev/null | sed -e 's,/Makefile$$,,g'`; do \
+    @for dir in `find . -name *Makefile | egrep -v '^./Makefile' | sed -e 's,/Makefile$$,,g'`; do \
       $(MAKE) -C $$dir $@;                           \
   done
testcases/open_posix_testsuite/scripts/locate-test +1 -1
index 27f0bb5..e4ef994 100755
@@ -92,7 +92,7 @@ runnable)
   # waltz down the tools directory and try and build t0 (which doesn't
   # make sense as it's a tool, not a test). Better criterion needs to
   # be established for this file.
-    find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools'
+    find "$WHERE/conformance" "$WHERE/stress" -type f -name '*[0-9a-z].c' -o -name '[0-9]*-[0-9]*.sh' | grep -v buildonly | grep -v '^./tools' | grep -v 'testfrmw.c$'
   find "$WHERE/functional" -type f -name '*.c'
   ;;
 test-tools)
testcases/open_posix_testsuite/stress/Makefile +0 -0
index b09527f..d6872a9 100644
@@ -5,7 +5,7 @@
 #
 

all clean install test:

testcases/open_posix_testsuite/stress/Makefile +1 -2
-    @for dir in `ls -d */Makefile 2>/dev/null | sed -e 's,/Makefile$$,,g'`; do \
+    @for dir in `find . -name *Makefile | egrep -v '^./Makefile' | sed -e 's,/Makefile$$,,g'`; do \
       $(MAKE) -C $$dir $@;                          \
   done
 
--

2.6.2

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw

PATCH 1/1 open_posix_testsuite: Fix compilation issues

In reply to Zou Wei

Hi!

Quoted 2 lines

Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS

Just linking with -lpthread is not correct way how to compile pthread programs on Linux, we have to add -pthread to both CLFAGS and LDFLAGS.

I guess that we should also default to the output of getconf for pthread CFLAGS and LDFLAGS if available[1]. Unfortunately it looks like this is not implemented on Linux yet.

So if getconf fails we will have to probably fallback to per-OS table of CFLAGS and LDFLAGS.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tagtcjh_25

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

Hi Cyril,

So we need to add -pthread to both CFLAGS and LDFLAGS to avoid the compilation and linking problem?

Best Regards
Zou Wei

-----????-----
???: Cyril Hrubis [mailto:[email protected]]
????: 2020?3?18? 4:52
???: Zouwei (Samuel) <[email protected]>
??: [email protected]
??: Re: [LTP] [PATCH] open_posix_testsuite: Fix compilation issues

Hi!

Quoted 2 lines

Fix compilation issues:
1. Add the '-lpthread -lrt -lm' config into LDFLAGS

Just linking with -lpthread is not correct way how to compile pthread programs on Linux, we have to add -pthread to both CLFAGS and LDFLAGS.

I guess that we should also default to the output of getconf for pthread CFLAGS and LDFLAGS if available[1]. Unfortunately it looks like this is not implemented on Linux yet.

So if getconf fails we will have to probably fallback to per-OS table of CFLAGS and LDFLAGS.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tagtcjh_25

--
Cyril Hrubis
[email protected]