Index: elfcopy/main.c =================================================================== --- elfcopy/main.c +++ elfcopy/main.c @@ -1453,6 +1453,22 @@ exit(EXIT_SUCCESS); } +/* + * Compare the ending of s with end. + */ +static int +strrcmp(const char *s, const char *end) +{ + size_t endlen, slen; + + slen = strlen(s); + endlen = strlen(end); + + if (slen >= endlen) + s += slen - endlen; + return (strcmp(s, end)); +} + int main(int argc, char **argv) { @@ -1486,9 +1502,9 @@ if ((ecp->progname = ELFTC_GETPROGNAME()) == NULL) ecp->progname = "elfcopy"; - if (strcmp(ecp->progname, "strip") == 0) + if (strrcmp(ecp->progname, "strip") == 0) strip_main(ecp, argc, argv); - else if (strcmp(ecp->progname, "mcs") == 0) + else if (strrcmp(ecp->progname, "mcs") == 0) mcs_main(ecp, argc, argv); else elfcopy_main(ecp, argc, argv); Index: test/elfcopy/func.sh =================================================================== --- test/elfcopy/func.sh +++ test/elfcopy/func.sh @@ -178,6 +178,28 @@ fi } +# Grep stdout for a specified string. +# +check_stdout() +{ + incct ${TOTALCT} + if grep -q "$@" ${OUTDIR}/${TC}.out; then + echo "${TC} stdout - ok" + incct ${PASSEDCT} + fi +} + +# Grep stderr for a specified string. +# +check_stderr() +{ + incct ${TOTALCT} + if grep -q "$@" ${OUTDIR}/${TC}.err; then + echo "${TC} stderr - ok" + incct ${PASSEDCT} + fi +} + # `innct' increase specified counter by 1. incct() { if [ $# -ne 1 ]; then Index: test/elfcopy/tc/strip-basename-1/strip-basename-1.sh =================================================================== --- /dev/null +++ test/elfcopy/tc/strip-basename-1/strip-basename-1.sh @@ -0,0 +1,7 @@ +# $Id$ +# Test that the program name switch (elfcopy/mcs/strip) works if the name +# has a prefix. +inittest strip-basename-1 tc/strip-basename-1 +cp ${STRIP} ${TESTDIR}/prefix-strip +runcmd "${TESTDIR}/prefix-strip -h" work true +check_stderr "Discard information from ELF objects"