head     1.1;
branch   1.1.1;
access   ;
symbols  LTP_20031204:1.1.1.1 LINUX_TEST_PROJECT:1.1.1;
locks    ; strict;
comment  @# @;


1.1
date     2003.12.31.08.57.47;  author mtm;  state Exp;
branches 1.1.1.1;
next     ;

1.1.1.1
date     2003.12.31.08.57.47;  author mtm;  state Exp;
branches ;
next     ;


desc
@@



1.1
log
@Initial revision
@
text
@#!/bin/sh
#
#   Copyright (c) International Business Machines  Corp., 2000
#
#   This program is free software;  you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
#   the GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this pronram;  if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
#  FILE   : nm01
#
#  PURPOSE: To test the basic functionality of the `nm` command.
#
#  HISTORY:
#    06/01 Robbie Williamson (robbiew@@us.ibm.com)
#     -Ported
#
#
#---------------------------------------------------------------------------
#Uncomment line below for debug output
#trace_logic=${trace_logic:-"set -x"}

TCtmp=${TCtmp:-/tmp/nm$$}
TCdat=${TCdat:-`pwd`}
LOOP=1
do_setup()
{
$trace_logic
  mkdir $TCtmp
  cc -o $TCtmp/nmfile $TCdat/nmfile.c
  cc -o $TCtmp/nmfile1 $TCdat/nmfile1.c
  cc -o $TCtmp/nmfile2 $TCdat/nmfile2.c
  cc -o $TCtmp/nmfile3 $TCdat/nmfile3.c
}

do_cleanup()
{
$trace_logic
  rm -rf $TCtmp
}

do_test()
{
$trace_logic
TCRESULT=0
while [ $LOOP -gt 0 ]
do
echo "-------System test for nm command------"
cd $TCdat
ar -cr $TCtmp/lib.a nmfile1.o nmfile1.o nmfile2.o nmfile3.o

# -A  Displays either the full path name or library name of an object
# on each line.                   

# CODE
RC1=0
RC2=0 

mkdir -p $TCtmp/a/b/c/d

nm -f posix -A $TCtmp/lib.a | grep "$TCtmp/lib.a\[nmfile2.o\]\:" 2>&1 1>/dev/null
RC1=$? 
cp $TCtmp/lib.a $TCtmp/a/b/c/d/
nm -f posix -A $TCtmp/a/b/c/d/lib.a | grep "$TCtmp/a/b/c/d/lib.a\[nmfile2.o\]\:"  2>&1 1>/dev/null
RC2=$? 


if [ $RC1 -eq  '0' ] && [ $RC2 -eq '0' ] 
then
	echo "-)1"
else
	echo "nm -A: FAIL" 
	do_cleanup
	exit 1
fi
#-------------------------------------------------------------------------------

#The nm -g Displays only external (global)symbols.

# CODE

COUNT=0
COUNT=`nm -f posix -g $TCtmp/nmfile1 | awk '{print $2 }' | grep "[a,b,d,f,t]"  | wc -l` 2>&1 1>/dev/null
if [ $COUNT -eq 0 ] 
then
	echo "-)2"
else
	echo "nm -g: FAIL"
	do_cleanup
	exit 1
fi
#-------------------------------------------------------------------------------
# -t o Displays a symbol's value as an octal rather than     
# a decimal number.               

# CODE
nm -f posix -t o $TCtmp/nmfile1 | awk '{print $3}' | grep "[8-9]" >/dev/null 2>&1
if [ $? -eq "1" ] 
then
	echo "-)3"
else
	echo "nm -t o: FAIL"
	do_cleanup
	exit 1	
fi
#-------------------------------------------------------------------------------

# -f sysv Displays information in a SysV output format 
# CODE

count=0
nm -f sysv $TCtmp/nmfile1 | grep Name > /dev/null 2>&1
count=$?
if [ $count -eq 0 ]
then
	echo "-)4"
else
	echo "nm -f sysv: FAIL"
	do_cleanup
	exit 1
fi

#-------------------------------------------------------------------------------

# -f bsd Displays information in a BSD output format 
# CODE
nm -f bsd $TCtmp/nmfile1 | grep printf | awk '{print $2}' > $TCtmp/nm.diff1
nm -f posix $TCtmp/nmfile1 | grep printf | awk '{print $1}' > $TCtmp/nm.diff2
diff $TCtmp/nm.diff1 $TCtmp/nm.diff2
if [ $? -eq 0  ]
then
	echo "-)5"
else
	echo "nm -f bsd: FAIL"
	do_cleanup
	exit 1
fi

#-----------------------------------------------------------------------------
#-u Displays only undefined symbols.Local and Global

# CODE
COUNT=0
nm -f sysv -u $TCtmp/nmfile1 | grep "Undefined symbols from" 2>&1 1>/dev/null
if [ $? -eq 0 ]
then
	echo "-)6"
else
	echo "nm -u: FAIL"
	do_cleanup
	exit 1
fi

#-----------------------------------------------------------------------------

# -v  Sorts output by value instead of alphabetically.
# CODE
nm $TCtmp/nmfile1 | sort | awk '{print $1}'| grep [0-9] > $TCtmp/nm.res1
nm -v $TCtmp/nmfile1 | awk '{print $1}' | grep [0-9] > $TCtmp/nm.res2
diff $TCtmp/nm.res1 $TCtmp/nm.res2 2>&1 1>/dev/null

if [ $? -eq 0 ]
then
	echo "-)7"
else
	echo "nm -v: FAIL"
	do_cleanup
	exit 1
fi
#------------------------------------------------------------------------------
# -s Print archive index.
# CODE

nm -s $TCtmp/lib.a | grep "index" 2>&1 1>/dev/null
if [ $? -eq 0 ]
then
	echo "-)8"
else
     	echo "nm -s: FAIL"
	do_cleanup
	exit 1
fi
#-----------------------------------------------------------------------------

LOOP=`expr $LOOP - 1`
done

echo "nm01: PASS"
do_cleanup
exit 0
}

#MAIN
do_setup
do_test


@


1.1.1.1
log
@Initial import of the Linux Test Project (http://ltp.sourceforge.net).

This import is minus the Posix test suite, which will be imported separately,
and the HPI suite, which doesn't concern us.
@
text
@@
