How to use test-nlist

2019-05-23 Thread Yu, Mingli

Hi Expert,

I run some tests about elfutils, but one test as test-nlist always fails 
as below:


# ./tests/test-nlist
nlist failed

# cd tests
# ./test-nlist  -d
nl[0].n_name = "var"
nl[0].n_value = 0
nl[0].n_scnum = 0
nl[0].n_type = 0
nl[0].n_sclass = 0
nl[0].n_numaux = 0

nl[1].n_name = "bss"
nl[1].n_value = 0
nl[1].n_scnum = 0
nl[1].n_type = 0
nl[1].n_sclass = 0
nl[1].n_numaux = 0

nl[2].n_name = "main"
nl[2].n_value = 0
nl[2].n_scnum = 0
nl[2].n_type = 0
nl[2].n_sclass = 0
nl[2].n_numaux = 0

nl[3].n_name = "foo"
nl[3].n_value = 0
nl[3].n_scnum = 0
nl[3].n_type = 0
nl[3].n_sclass = 0
nl[3].n_numaux = 0

nl[4].n_name = "not-there"
nl[4].n_value = 0
nl[4].n_scnum = 0
nl[4].n_type = 0
nl[4].n_sclass = 0
nl[4].n_numaux = 0
# echo $?
1


Any hints?

Thanks,


Re: [PATCH v2] skip the test when gcc not deployed

2019-05-23 Thread Mark Wielaard
Hi,

On Tue, May 21, 2019 at 03:33:06PM +0800, mingli...@windriver.com wrote:
> Skip the tests which depend on gcc when
> gcc not deployed.

What exactly are you trying to do?
When would you run make check without having gcc installed?
If this is to check against an alternative compiler?

In the last case it might be better to make CC available to the tests
environment. Does something like the following work for you?

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 80900e42d..4b7703d8a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -445,7 +445,8 @@ installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \
  export abs_top_builddir; \
  export libdir; export bindir; \
  export LC_ALL; export LANG; export VALGRIND_CMD; \
- NM=$(NM); export NM;
+ NM=$(NM); export NM; \
+ CC=$(CC); export CC;
 installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
 installed $(tests_rpath) \
 '$(program_transform_name)'
@@ -459,7 +460,8 @@ TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; 
VALGRIND_CMD=$(valgrind_cmd); \
export abs_srcdir; export abs_builddir; \
export abs_top_builddir; \
export LC_ALL; export LANG; export VALGRIND_CMD; \
-   NM=$(NM); export NM;
+   NM=$(NM); export NM; \
+   CC=$(CC); export CC;
 LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
   
$(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm
 
diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
index a6be62bbc..3fe28084f 100755
--- a/tests/run-disasm-x86-64.sh
+++ b/tests/run-disasm-x86-64.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
   x86_64)
 tempfiles testfile45.o
 testfiles testfile45.S testfile45.expect
-gcc -m64 -c -o testfile45.o testfile45.S
+$CC -m64 -c -o testfile45.o testfile45.S
 testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < 
testfile45.expect
 ;;
 esac
diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
index 28a3df740..48cd18030 100755
--- a/tests/run-disasm-x86.sh
+++ b/tests/run-disasm-x86.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
   x86_64 | i?86 )
 tempfiles testfile44.o
 testfiles testfile44.S testfile44.expect
-gcc -m32 -c -o testfile44.o testfile44.S
+$CC -m32 -c -o testfile44.o testfile44.S
 testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < 
testfile44.expect
 ;;
 esac
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
index 13038195d..b30b39f1a 100755
--- a/tests/run-strip-g.sh
+++ b/tests/run-strip-g.sh
@@ -25,7 +25,7 @@
 tempfiles a.out strip.out debug.out readelf.out
 
 echo Create debug a.out.
-echo "int main() { return 1; }" | gcc -g -xc -
+echo "int main() { return 1; }" | $CC -g -xc -
 
 echo strip -g to file with debug file
 testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
index 914fdfbf0..4867a82fa 100755
--- a/tests/run-strip-nothing.sh
+++ b/tests/run-strip-nothing.sh
@@ -23,7 +23,7 @@
 tempfiles a.out strip.out debug.out
 
 # Create no-debug a.out.
-echo "int main() { return 1; }" | gcc -s -xc -
+echo "int main() { return 1; }" | $CC -s -xc -
 
 # strip to file
 testrun ${abs_top_builddir}/src/strip -g -o strip.out ||



Re: How to use test-nlist

2019-05-23 Thread Mark Wielaard
On Thu, May 23, 2019 at 04:52:39PM +0800, Yu, Mingli wrote:
> I run some tests about elfutils, but one test as test-nlist always fails as
> below:
> 
> # ./tests/test-nlist
> nlist failed

You are supposed to run it with make check.
make check TESTS=test-nlist

test-nlist tries to run nlist on itself.
So it has to be in the current working directory.
As you do below:

> # cd tests
> # ./test-nlist  -d
> nl[0].n_name = "var"
> nl[0].n_value = 0
> nl[0].n_scnum = 0
> nl[0].n_type = 0
> nl[0].n_sclass = 0
> nl[0].n_numaux = 0
> 
> nl[1].n_name = "bss"
> nl[1].n_value = 0
> nl[1].n_scnum = 0
> nl[1].n_type = 0
> nl[1].n_sclass = 0
> nl[1].n_numaux = 0
> 
> nl[2].n_name = "main"
> nl[2].n_value = 0
> nl[2].n_scnum = 0
> nl[2].n_type = 0
> nl[2].n_sclass = 0
> nl[2].n_numaux = 0
> 
> nl[3].n_name = "foo"
> nl[3].n_value = 0
> nl[3].n_scnum = 0
> nl[3].n_type = 0
> nl[3].n_sclass = 0
> nl[3].n_numaux = 0
> 
> nl[4].n_name = "not-there"
> nl[4].n_value = 0
> nl[4].n_scnum = 0
> nl[4].n_type = 0
> nl[4].n_sclass = 0
> nl[4].n_numaux = 0
> # echo $?
> 1

For some reason all the n_ fields come out as zero.  That is not what
the test expects (except for the last "not-there" entry. It should
look somethng like:

nl[0].n_name = "var"
nl[0].n_value = 16456
nl[0].n_scnum = 24
nl[0].n_type = 1
nl[0].n_sclass = 0
nl[0].n_numaux = 0

nl[1].n_name = "bss"
nl[1].n_value = 16464
nl[1].n_scnum = 25
nl[1].n_type = 1
nl[1].n_sclass = 0
nl[1].n_numaux = 0

nl[2].n_name = "main"
nl[2].n_value = 4224
nl[2].n_scnum = 14
nl[2].n_type = 2
nl[2].n_sclass = 0
nl[2].n_numaux = 0

nl[3].n_name = "foo"
nl[3].n_value = 4880
nl[3].n_scnum = 14
nl[3].n_type = 2
nl[3].n_sclass = 0
nl[3].n_numaux = 0

nl[4].n_name = "not-there"
nl[4].n_value = 0
nl[4].n_scnum = 0
nl[4].n_type = 0
nl[4].n_sclass = 0
nl[4].n_numaux = 0

Basically nlist fills in the n_value and n_scnum with the st_value and
st_shndx of the symbol named if found.

As you can see for me it corresponds to the values found by:

$ eu-readelf -s ./test-nlist | egrep ' (var|bss|main|foo)'
   58: 4048  4 OBJECT  GLOBAL DEFAULT   24 var
   61: 4050  4 OBJECT  GLOBAL DEFAULT   25 bss
   66: 1310  3 FUNCGLOBAL DEFAULT   14 foo
   71: 1080408 FUNCGLOBAL DEFAULT   14 main

Hope that helps you debug.

Cheers,

Mark


Re: How to use test-nlist

2019-05-23 Thread Yu, Mingli




On 2019年05月23日 19:50, Mark Wielaard wrote:

On Thu, May 23, 2019 at 04:52:39PM +0800, Yu, Mingli wrote:

I run some tests about elfutils, but one test as test-nlist always fails as
below:

# ./tests/test-nlist
nlist failed


You are supposed to run it with make check.
make check TESTS=test-nlist

test-nlist tries to run nlist on itself.
So it has to be in the current working directory.


Thanks Mark for your respond!
As you said "So it has to be in the current working directory.", what do 
you mean? test-nlist needs to locate in the current working directory?



As you do below:


# cd tests
# ./test-nlist  -d
nl[0].n_name = "var"
nl[0].n_value = 0
nl[0].n_scnum = 0
nl[0].n_type = 0
nl[0].n_sclass = 0
nl[0].n_numaux = 0

nl[1].n_name = "bss"
nl[1].n_value = 0
nl[1].n_scnum = 0
nl[1].n_type = 0
nl[1].n_sclass = 0
nl[1].n_numaux = 0

nl[2].n_name = "main"
nl[2].n_value = 0
nl[2].n_scnum = 0
nl[2].n_type = 0
nl[2].n_sclass = 0
nl[2].n_numaux = 0

nl[3].n_name = "foo"
nl[3].n_value = 0
nl[3].n_scnum = 0
nl[3].n_type = 0
nl[3].n_sclass = 0
nl[3].n_numaux = 0

nl[4].n_name = "not-there"
nl[4].n_value = 0
nl[4].n_scnum = 0
nl[4].n_type = 0
nl[4].n_sclass = 0
nl[4].n_numaux = 0
# echo $?
1


For some reason all the n_ fields come out as zero.  That is not what
the test expects (except for the last "not-there" entry. It should
look somethng like:

nl[0].n_name = "var"
nl[0].n_value = 16456
nl[0].n_scnum = 24
nl[0].n_type = 1
nl[0].n_sclass = 0
nl[0].n_numaux = 0

nl[1].n_name = "bss"
nl[1].n_value = 16464
nl[1].n_scnum = 25
nl[1].n_type = 1
nl[1].n_sclass = 0
nl[1].n_numaux = 0

nl[2].n_name = "main"
nl[2].n_value = 4224
nl[2].n_scnum = 14
nl[2].n_type = 2
nl[2].n_sclass = 0
nl[2].n_numaux = 0

nl[3].n_name = "foo"
nl[3].n_value = 4880
nl[3].n_scnum = 14
nl[3].n_type = 2
nl[3].n_sclass = 0
nl[3].n_numaux = 0

nl[4].n_name = "not-there"
nl[4].n_value = 0
nl[4].n_scnum = 0
nl[4].n_type = 0
nl[4].n_sclass = 0
nl[4].n_numaux = 0

Basically nlist fills in the n_value and n_scnum with the st_value and
st_shndx of the symbol named if found.

As you can see for me it corresponds to the values found by:

$ eu-readelf -s ./test-nlist | egrep ' (var|bss|main|foo)'
58: 4048  4 OBJECT  GLOBAL DEFAULT   24 var
61: 4050  4 OBJECT  GLOBAL DEFAULT   25 bss
66: 1310  3 FUNCGLOBAL DEFAULT   14 foo
71: 1080408 FUNCGLOBAL DEFAULT   14 main


# which eu-readelf
/usr/bin/eu-readelf

# /usr/bin/eu-readelf -s tests/test-nlist
Symbol table [ 5] '.dynsym' contains 11 entries:
 1 local symbol  String table: [ 6] '.dynstr'
  Num:Value   Size TypeBind   Vis  Ndx Name
0:   0 NOTYPE  LOCAL  DEFAULTUNDEF
1:   0 NOTYPE  WEAK   DEFAULTUNDEF 
_ITM_deregisterTMCloneTable
2:   0 FUNCGLOBAL DEFAULTUNDEF 
puts@GLIBC_2.2.5 (2)
3:   0 FUNCGLOBAL DEFAULTUNDEF 
__stack_chk_fail@GLIBC_2.4 (3)
4:   0 FUNCGLOBAL DEFAULTUNDEF 
__libc_start_main@GLIBC_2.2.5 (2)
5:   0 NOTYPE  WEAK   DEFAULTUNDEF 
__gmon_start__
6:   0 FUNCGLOBAL DEFAULTUNDEF 
nlist@ELFUTILS_1.0 (4)
7:   0 FUNCGLOBAL DEFAULTUNDEF 
__printf_chk@GLIBC_2.3.4 (5)
8:   0 FUNCGLOBAL DEFAULTUNDEF 
exit@GLIBC_2.2.5 (2)
9:   0 NOTYPE  WEAK   DEFAULTUNDEF 
_ITM_registerTMCloneTable
   10:   0 FUNCWEAK   DEFAULTUNDEF 
__cxa_finalize@GLIBC_2.2.5 (2)


Thanks,



Hope that helps you debug.

Cheers,

Mark



Re: How to use test-nlist

2019-05-23 Thread Mark Wielaard
On Fri, May 24, 2019 at 11:00:57AM +0800, Yu, Mingli wrote:
> On 2019年05月23日 19:50, Mark Wielaard wrote:
> > > # ./tests/test-nlist
> > > nlist failed
> > 
> > You are supposed to run it with make check.
> > make check TESTS=test-nlist
> > 
> > test-nlist tries to run nlist on itself.
> > So it has to be in the current working directory.
> 
> Thanks Mark for your respond!
> As you said "So it has to be in the current working directory.", what do you
> mean? test-nlist needs to locate in the current working directory?

Yes. See the source code.
The test tries to run nlist on "./test-nlist".

> > Basically nlist fills in the n_value and n_scnum with the st_value and
> > st_shndx of the symbol named if found.
> > 
> > As you can see for me it corresponds to the values found by:
> > 
> > $ eu-readelf -s ./test-nlist | egrep ' (var|bss|main|foo)'
> > 58: 4048  4 OBJECT  GLOBAL DEFAULT   24 var
> > 61: 4050  4 OBJECT  GLOBAL DEFAULT   25 bss
> > 66: 1310  3 FUNCGLOBAL DEFAULT   14 foo
> > 71: 1080408 FUNCGLOBAL DEFAULT   14 main
> 
> # which eu-readelf
> /usr/bin/eu-readelf
> 
> # /usr/bin/eu-readelf -s tests/test-nlist
> Symbol table [ 5] '.dynsym' contains 11 entries:
>  1 local symbol  String table: [ 6] '.dynstr'
>   Num:Value   Size TypeBind   Vis  Ndx Name
> 0:   0 NOTYPE  LOCAL  DEFAULTUNDEF
> 1:   0 NOTYPE  WEAK   DEFAULTUNDEF
> _ITM_deregisterTMCloneTable
> 2:   0 FUNCGLOBAL DEFAULTUNDEF
> puts@GLIBC_2.2.5 (2)
> 3:   0 FUNCGLOBAL DEFAULTUNDEF
> __stack_chk_fail@GLIBC_2.4 (3)
> 4:   0 FUNCGLOBAL DEFAULTUNDEF
> __libc_start_main@GLIBC_2.2.5 (2)
> 5:   0 NOTYPE  WEAK   DEFAULTUNDEF
> __gmon_start__
> 6:   0 FUNCGLOBAL DEFAULTUNDEF
> nlist@ELFUTILS_1.0 (4)
> 7:   0 FUNCGLOBAL DEFAULTUNDEF
> __printf_chk@GLIBC_2.3.4 (5)
> 8:   0 FUNCGLOBAL DEFAULTUNDEF
> exit@GLIBC_2.2.5 (2)
> 9:   0 NOTYPE  WEAK   DEFAULTUNDEF
> _ITM_registerTMCloneTable
>10:   0 FUNCWEAK   DEFAULTUNDEF
> __cxa_finalize@GLIBC_2.2.5 (2)

For some reason your test-nlist doesn't have an .symtab.
Make sure that when you build the tests CLFAGS contains -g.
And the that test binary isn't accidentially stripped afterwards.

Cheers,

Mark


Re: How to use test-nlist

2019-05-23 Thread Yu, Mingli




On 2019年05月24日 14:23, Mark Wielaard wrote:

On Fri, May 24, 2019 at 11:00:57AM +0800, Yu, Mingli wrote:

On 2019年05月23日 19:50, Mark Wielaard wrote:

# ./tests/test-nlist
nlist failed


You are supposed to run it with make check.
make check TESTS=test-nlist

test-nlist tries to run nlist on itself.
So it has to be in the current working directory.


Thanks Mark for your respond!
As you said "So it has to be in the current working directory.", what do you
mean? test-nlist needs to locate in the current working directory?


Yes. See the source code.
The test tries to run nlist on "./test-nlist".


Which package provides nlist, I didn't found nlist in my system.

Thanks,




Basically nlist fills in the n_value and n_scnum with the st_value and
st_shndx of the symbol named if found.

As you can see for me it corresponds to the values found by:

$ eu-readelf -s ./test-nlist | egrep ' (var|bss|main|foo)'
 58: 4048  4 OBJECT  GLOBAL DEFAULT   24 var
 61: 4050  4 OBJECT  GLOBAL DEFAULT   25 bss
 66: 1310  3 FUNCGLOBAL DEFAULT   14 foo
 71: 1080408 FUNCGLOBAL DEFAULT   14 main


# which eu-readelf
/usr/bin/eu-readelf

# /usr/bin/eu-readelf -s tests/test-nlist
Symbol table [ 5] '.dynsym' contains 11 entries:
  1 local symbol  String table: [ 6] '.dynstr'
   Num:Value   Size TypeBind   Vis  Ndx Name
 0:   0 NOTYPE  LOCAL  DEFAULTUNDEF
 1:   0 NOTYPE  WEAK   DEFAULTUNDEF
_ITM_deregisterTMCloneTable
 2:   0 FUNCGLOBAL DEFAULTUNDEF
puts@GLIBC_2.2.5 (2)
 3:   0 FUNCGLOBAL DEFAULTUNDEF
__stack_chk_fail@GLIBC_2.4 (3)
 4:   0 FUNCGLOBAL DEFAULTUNDEF
__libc_start_main@GLIBC_2.2.5 (2)
 5:   0 NOTYPE  WEAK   DEFAULTUNDEF
__gmon_start__
 6:   0 FUNCGLOBAL DEFAULTUNDEF
nlist@ELFUTILS_1.0 (4)
 7:   0 FUNCGLOBAL DEFAULTUNDEF
__printf_chk@GLIBC_2.3.4 (5)
 8:   0 FUNCGLOBAL DEFAULTUNDEF
exit@GLIBC_2.2.5 (2)
 9:   0 NOTYPE  WEAK   DEFAULTUNDEF
_ITM_registerTMCloneTable
10:   0 FUNCWEAK   DEFAULTUNDEF
__cxa_finalize@GLIBC_2.2.5 (2)


For some reason your test-nlist doesn't have an .symtab.
Make sure that when you build the tests CLFAGS contains -g.
And the that test binary isn't accidentially stripped afterwards.

Cheers,

Mark



Re: How to use test-nlist

2019-05-23 Thread Yu, Mingli




On 2019年05月24日 14:36, Yu, Mingli wrote:



On 2019年05月24日 14:23, Mark Wielaard wrote:

On Fri, May 24, 2019 at 11:00:57AM +0800, Yu, Mingli wrote:

On 2019年05月23日 19:50, Mark Wielaard wrote:

# ./tests/test-nlist
nlist failed


You are supposed to run it with make check.
make check TESTS=test-nlist

test-nlist tries to run nlist on itself.
So it has to be in the current working directory.


Thanks Mark for your respond!
As you said "So it has to be in the current working directory.", what
do you
mean? test-nlist needs to locate in the current working directory?


Yes. See the source code.
The test tries to run nlist on "./test-nlist".


Which package provides nlist, I didn't found nlist in my system.


Sorry, please ignore this question. I misunderstood just now and thought 
there should be two file nlist and test-nlist need to locate in the 
current working directory.


And I noticed the source code and already run as "./test-nlist", but 
Seems it doesn't work as expected.

# ./test-nlist
# echo $?
1
# ./test-nlist -d
nl[0].n_name = "var"
nl[0].n_value = 0
nl[0].n_scnum = 0
nl[0].n_type = 0
nl[0].n_sclass = 0
nl[0].n_numaux = 0

nl[1].n_name = "bss"
nl[1].n_value = 0
nl[1].n_scnum = 0
nl[1].n_type = 0
nl[1].n_sclass = 0
nl[1].n_numaux = 0

nl[2].n_name = "main"
nl[2].n_value = 0
nl[2].n_scnum = 0
nl[2].n_type = 0
nl[2].n_sclass = 0
nl[2].n_numaux = 0

nl[3].n_name = "foo"
nl[3].n_value = 0
nl[3].n_scnum = 0
nl[3].n_type = 0
nl[3].n_sclass = 0
nl[3].n_numaux = 0

nl[4].n_name = "not-there"
nl[4].n_value = 0
nl[4].n_scnum = 0
nl[4].n_type = 0
nl[4].n_sclass = 0
nl[4].n_numaux = 0
# echo $?
1

Thanks,



Thanks,




Basically nlist fills in the n_value and n_scnum with the st_value and
st_shndx of the symbol named if found.

As you can see for me it corresponds to the values found by:

$ eu-readelf -s ./test-nlist | egrep ' (var|bss|main|foo)'
 58: 4048  4 OBJECT  GLOBAL DEFAULT   24 var
 61: 4050  4 OBJECT  GLOBAL DEFAULT   25 bss
 66: 1310  3 FUNCGLOBAL DEFAULT   14 foo
 71: 1080408 FUNCGLOBAL DEFAULT   14 main


# which eu-readelf
/usr/bin/eu-readelf

# /usr/bin/eu-readelf -s tests/test-nlist
Symbol table [ 5] '.dynsym' contains 11 entries:
  1 local symbol  String table: [ 6] '.dynstr'
   Num:Value   Size TypeBind   Vis  Ndx Name
 0:   0 NOTYPE  LOCAL  DEFAULTUNDEF
 1:   0 NOTYPE  WEAK   DEFAULTUNDEF
_ITM_deregisterTMCloneTable
 2:   0 FUNCGLOBAL DEFAULTUNDEF
puts@GLIBC_2.2.5 (2)
 3:   0 FUNCGLOBAL DEFAULTUNDEF
__stack_chk_fail@GLIBC_2.4 (3)
 4:   0 FUNCGLOBAL DEFAULTUNDEF
__libc_start_main@GLIBC_2.2.5 (2)
 5:   0 NOTYPE  WEAK   DEFAULTUNDEF
__gmon_start__
 6:   0 FUNCGLOBAL DEFAULTUNDEF
nlist@ELFUTILS_1.0 (4)
 7:   0 FUNCGLOBAL DEFAULTUNDEF
__printf_chk@GLIBC_2.3.4 (5)
 8:   0 FUNCGLOBAL DEFAULTUNDEF
exit@GLIBC_2.2.5 (2)
 9:   0 NOTYPE  WEAK   DEFAULTUNDEF
_ITM_registerTMCloneTable
10:   0 FUNCWEAK   DEFAULTUNDEF
__cxa_finalize@GLIBC_2.2.5 (2)


For some reason your test-nlist doesn't have an .symtab.
Make sure that when you build the tests CLFAGS contains -g.
And the that test binary isn't accidentially stripped afterwards.

Cheers,

Mark





Re: How to use test-nlist

2019-05-23 Thread Mark Wielaard
On Fri, May 24, 2019 at 02:36:15PM +0800, Yu, Mingli wrote:
> > Yes. See the source code.
> > The test tries to run nlist on "./test-nlist".
> 
> Which package provides nlist, I didn't found nlist in my system.

nlist is a function in libelf, one of the libraries of elfutils.

Cheers,

Mark


Re: [PATCH v2] skip the test when gcc not deployed

2019-05-23 Thread Yu, Mingli




On 2019年05月23日 19:28, Mark Wielaard wrote:

Hi,

On Tue, May 21, 2019 at 03:33:06PM +0800, mingli...@windriver.com wrote:

Skip the tests which depend on gcc when
gcc not deployed.


What exactly are you trying to do?
When would you run make check without having gcc installed?


Thanks Mark!
I just run the check without having gcc installed, and of cource no 
compiler installed in my test env.


Thanks,


If this is to check against an alternative compiler?

In the last case it might be better to make CC available to the tests
environment. Does something like the following work for you?

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 80900e42d..4b7703d8a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -445,7 +445,8 @@ installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \
  export abs_top_builddir; \
  export libdir; export bindir; \
  export LC_ALL; export LANG; export VALGRIND_CMD; \
- NM=$(NM); export NM;
+ NM=$(NM); export NM; \
+ CC=$(CC); export CC;
  installed_LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
 installed $(tests_rpath) \
 '$(program_transform_name)'
@@ -459,7 +460,8 @@ TESTS_ENVIRONMENT = LC_ALL=C; LANG=C; 
VALGRIND_CMD=$(valgrind_cmd); \
export abs_srcdir; export abs_builddir; \
export abs_top_builddir; \
export LC_ALL; export LANG; export VALGRIND_CMD; \
-   NM=$(NM); export NM;
+   NM=$(NM); export NM; \
+   CC=$(CC); export CC;
  LOG_COMPILER = $(abs_srcdir)/test-wrapper.sh \
   
$(abs_top_builddir)/libdw:$(abs_top_builddir)/backends:$(abs_top_builddir)/libelf:$(abs_top_builddir)/libasm

diff --git a/tests/run-disasm-x86-64.sh b/tests/run-disasm-x86-64.sh
index a6be62bbc..3fe28084f 100755
--- a/tests/run-disasm-x86-64.sh
+++ b/tests/run-disasm-x86-64.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
x86_64)
  tempfiles testfile45.o
  testfiles testfile45.S testfile45.expect
-gcc -m64 -c -o testfile45.o testfile45.S
+$CC -m64 -c -o testfile45.o testfile45.S
  testrun_compare ${abs_top_builddir}/src/objdump -d testfile45.o < 
testfile45.expect
  ;;
  esac
diff --git a/tests/run-disasm-x86.sh b/tests/run-disasm-x86.sh
index 28a3df740..48cd18030 100755
--- a/tests/run-disasm-x86.sh
+++ b/tests/run-disasm-x86.sh
@@ -22,7 +22,7 @@ case "`uname -m`" in
x86_64 | i?86 )
  tempfiles testfile44.o
  testfiles testfile44.S testfile44.expect
-gcc -m32 -c -o testfile44.o testfile44.S
+$CC -m32 -c -o testfile44.o testfile44.S
  testrun_compare ${abs_top_builddir}/src/objdump -d testfile44.o < 
testfile44.expect
  ;;
  esac
diff --git a/tests/run-strip-g.sh b/tests/run-strip-g.sh
index 13038195d..b30b39f1a 100755
--- a/tests/run-strip-g.sh
+++ b/tests/run-strip-g.sh
@@ -25,7 +25,7 @@
  tempfiles a.out strip.out debug.out readelf.out

  echo Create debug a.out.
-echo "int main() { return 1; }" | gcc -g -xc -
+echo "int main() { return 1; }" | $CC -g -xc -

  echo strip -g to file with debug file
  testrun ${abs_top_builddir}/src/strip -g -o strip.out -f debug.out ||
diff --git a/tests/run-strip-nothing.sh b/tests/run-strip-nothing.sh
index 914fdfbf0..4867a82fa 100755
--- a/tests/run-strip-nothing.sh
+++ b/tests/run-strip-nothing.sh
@@ -23,7 +23,7 @@
  tempfiles a.out strip.out debug.out

  # Create no-debug a.out.
-echo "int main() { return 1; }" | gcc -s -xc -
+echo "int main() { return 1; }" | $CC -s -xc -

  # strip to file
  testrun ${abs_top_builddir}/src/strip -g -o strip.out ||