From: Rob Savoye Date: Sat, 26 May 2001 05:55:28 +0000 (+0000) Subject: * acinclude.m4: Add DJ_AC_STL, which figures out if we're running X-Git-Tag: upstream/1.6.2~595 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4330bafff46c45742dc65b79a7e06196f0d89336;p=platform%2Fupstream%2Fdejagnu.git * acinclude.m4: Add DJ_AC_STL, which figures out if we're running libstdc++ version 2 or 3. * aclocal.m4: Regenerated. * configure.in: Add DJ_AC_STL. * configure: Regenerated. * dejagnu.h: Add the use of the std namespace, so we work with libstdc++ version 2 or 3. * testsuite/libdejagnu/unit.cc: Use setbuf() or pubsetbuff(), depending on the version. --- diff --git a/ChangeLog b/ChangeLog index e2896a6..efa0fc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-05-25 Rob Savoye + + * acinclude.m4: Add DJ_AC_STL, which figures out if we're running + libstdc++ version 2 or 3. + * aclocal.m4: Regenerated. + * configure.in: Add DJ_AC_STL. + * configure: Regenerated. + * dejagnu.h: Add the use of the std namespace, so we work with + libstdc++ version 2 or 3. + * testsuite/libdejagnu/unit.cc: Use setbuf() or pubsetbuff(), + depending on the version. + 2001-05-20 Stephane Carrez * baseboards/m68hc11-sim.exp: New file for 68HC11/68HC12 validation. diff --git a/acinclude.m4 b/acinclude.m4 index 20497d0..9f6cec4 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,3 +1,24 @@ +AC_DEFUN(DJ_AC_STL, [ +AC_MSG_CHECKING(for for STL versions) +AC_CACHE_VAL(ac_cv_stl,[ + AC_TRY_COMPILE([#include ], [ + using namespace std; + char bbuuff[5120]; + cout.rdbuf()->pubsetbuf(bbuuff, 5120); ], + ac_cv_stl=v3 + , + ac_cv_stl=v2 + ), +]) + +if test x"${ac_cv_stl}" != x"v2" ; then + AC_MSG_RESULT(v3) + AC_DEFINE(HAVE_STL3) +else + AC_MSG_RESULT(v2) +fi +]) + AC_DEFUN(DJ_AC_PATH_TCLSH, [ dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../ ../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../.. diff --git a/aclocal.m4 b/aclocal.m4 index 4884dc2..f5b577e 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -10,6 +10,27 @@ dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. +AC_DEFUN(DJ_AC_STL, [ +AC_MSG_CHECKING(for for STL versions) +AC_CACHE_VAL(ac_cv_stl,[ + AC_TRY_COMPILE([#include ], [ + using namespace std; + char bbuuff[5120]; + cout.rdbuf()->pubsetbuf(bbuuff, 5120); ], + ac_cv_stl=v3 + , + ac_cv_stl=v2 + ), +]) + +if test x"${ac_cv_stl}" != x"v2" ; then + AC_MSG_RESULT(v3) + AC_DEFINE(HAVE_STL3) +else + AC_MSG_RESULT(v2) +fi +]) + AC_DEFUN(DJ_AC_PATH_TCLSH, [ dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../ ../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../.. @@ -223,3 +244,12 @@ else $1_FALSE= fi]) + +dnl AM_PROG_LEX +dnl Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT +AC_DEFUN(AM_PROG_LEX, +[missing_dir=ifelse([$1],,`cd $ac_aux_dir && pwd`,$1) +AC_CHECK_PROGS(LEX, flex lex, "$missing_dir/missing flex") +AC_PROG_LEX +AC_DECL_YYTEXT]) + diff --git a/configure b/configure index 755e157..c780689 100755 --- a/configure +++ b/configure @@ -1358,10 +1358,302 @@ echo "$ac_t""${ac_cv_exeext}" 1>&6 ac_exeext=$EXEEXT +for ac_prog in 'bison -y' byacc +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1367: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_YACC="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +YACC="$ac_cv_prog_YACC" +if test -n "$YACC"; then + echo "$ac_t""$YACC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1398: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1419: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1453: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +missing_dir=`cd $ac_aux_dir && pwd` +for ac_prog in flex lex +do +# Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1483: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LEX="$ac_prog" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +LEX="$ac_cv_prog_LEX" +if test -n "$LEX"; then + echo "$ac_t""$LEX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +test -n "$LEX" && break +done +test -n "$LEX" || LEX=""$missing_dir/missing flex"" + +# Extract the first word of "flex", so it can be a program name with args. +set dummy flex; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1516: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LEX="flex" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex" +fi +fi +LEX="$ac_cv_prog_LEX" +if test -n "$LEX"; then + echo "$ac_t""$LEX" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$LEXLIB" +then + case "$LEX" in + flex*) ac_lib=fl ;; + *) ac_lib=l ;; + esac + echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 +echo "configure:1550: checking for yywrap in -l$ac_lib" >&5 +ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-l$ac_lib $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LEXLIB="-l$ac_lib" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +echo $ac_n "checking lex output file root""... $ac_c" 1>&6 +echo "configure:1592: checking lex output file root" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # The minimal lex program is just a single line: %%. But some broken lexes +# (Solaris, I think it was) want two %% lines, so accommodate them. +echo '%% +%%' | $LEX +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + { echo "configure: error: cannot find output from $LEX; giving up" 1>&2; exit 1; } +fi +fi + +echo "$ac_t""$ac_cv_prog_lex_root" 1>&6 +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6 +echo "configure:1613: checking whether yytext is a pointer" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c +ac_save_LIBS="$LIBS" +LIBS="$LIBS $LEXLIB" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_prog_lex_yytext_pointer=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +LIBS="$ac_save_LIBS" +rm -f "${LEX_OUTPUT_ROOT}.c" + +fi + +echo "$ac_t""$ac_cv_prog_lex_yytext_pointer" 1>&6 +if test $ac_cv_prog_lex_yytext_pointer = yes; then + cat >> confdefs.h <<\EOF +#define YYTEXT_POINTER 1 +EOF + +fi + + dirlist=".. ../../ ../../.. ../../../.. ../../../../.. ../../../../../.. ../../../../../../.. ../../../../../../../.. ../../../../../../../../.. ../../../../../../../../../.." echo $ac_n "checking for docbook tools""... $ac_c" 1>&6 -echo "configure:1365: checking for docbook tools" >&5 +echo "configure:1657: checking for docbook tools" >&5 # Check whether --with-oskith or --without-oskith was given. if test "${with_oskith+set}" = set; then withval="$with_oskith" @@ -1407,7 +1699,7 @@ dirlist=".. ../../ ../../../ ../../../../ ../../../../../ ../../../../../../ ../ /../../../../../.." no_itcl=true echo $ac_n "checking for the tclsh program""... $ac_c" 1>&6 -echo "configure:1411: checking for the tclsh program" >&5 +echo "configure:1703: checking for the tclsh program" >&5 # Check whether --with-tclinclude or --without-tclinclude was given. if test "${with_tclinclude+set}" = set; then withval="$with_tclinclude" @@ -1452,7 +1744,7 @@ if test x"${ac_cv_path_tclsh}" = x ; then # Extract the first word of "tclsh", so it can be a program name with args. set dummy tclsh; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1456: checking for $ac_word" >&5 +echo "configure:1748: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_tclsh'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1491,6 +1783,51 @@ TCLSH="${ac_cv_path_tclsh}" + +echo $ac_n "checking for for STL versions""... $ac_c" 1>&6 +echo "configure:1789: checking for for STL versions" >&5 +if eval "test \"`echo '$''{'ac_cv_stl'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + cat > conftest.$ac_ext < +int main() { + + using namespace std; + char bbuuff[5120]; + cout.rdbuf()->pubsetbuf(bbuuff, 5120); +; return 0; } +EOF +if { (eval echo configure:1805: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_stl=v3 + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_stl=v2 + +fi +rm -f conftest*, + +fi + + +if test x"${ac_cv_stl}" != x"v2" ; then + echo "$ac_t""v3" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_STL3 1 +EOF + +else + echo "$ac_t""v2" 1>&6 +fi + + BOARDS='$(boards)' CONFIG='$(config)' @@ -1613,7 +1950,7 @@ ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile doc/Makefile testsuite/Makefile example/Makefile -testsuite/libdejagnu/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +testsuite/libdejagnu/Makefile unitparse/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then diff --git a/configure.in b/configure.in index a857b63..df387b9 100644 --- a/configure.in +++ b/configure.in @@ -13,12 +13,18 @@ AC_PROG_CXX AC_PROG_INSTALL AC_EXEEXT +AC_PROG_YACC +AM_PROG_LEX + dnl we need the path to Docbook so we can build packages. DJ_AC_PATH_DOCBOOK dnl we need the path to the tcl shell to build a release DJ_AC_PATH_TCLSH +dnl we need to know if we have libstl v2 or v3 +DJ_AC_STL + dnl Level of indirection for automake macro (baseboards:boards_DATA) BOARDS='$(boards)' AC_SUBST(BOARDS) @@ -28,5 +34,5 @@ AC_SUBST(CONFIG) AC_CONFIG_SUBDIRS(example/calc) AC_OUTPUT(Makefile doc/Makefile testsuite/Makefile example/Makefile -testsuite/libdejagnu/Makefile) +testsuite/libdejagnu/Makefile unitparse/Makefile) diff --git a/dejagnu.h b/dejagnu.h index 7d6c7f7..9d51c47 100644 --- a/dejagnu.h +++ b/dejagnu.h @@ -63,6 +63,7 @@ totals (void) { #ifdef __cplusplus + #include #include #include @@ -110,12 +111,13 @@ OMANIP testout(int i) { #endif char *testout (int x) { - const int len = 128; - static char buf[len]; - static ostrstream oss(buf, len, ios::out); - oss.seekp(ios::beg); - oss << outstate[x] << ends; - return buf; + using namespace std; + const int len = 128; + static char buf[len]; + static ostrstream oss(buf, len, ios::out); + oss.seekp(ios::beg); + oss << outstate[x] << ends; + return buf; } enum teststate {FAILED, PASSED,UNTESTED,UNRESOLVED} laststate; @@ -123,7 +125,7 @@ enum teststate {FAILED, PASSED,UNTESTED,UNRESOLVED} laststate; class TestState { private: teststate laststate; - string lastmsg; + std::string lastmsg; public: TestState(void) { passed = 0; @@ -135,75 +137,76 @@ class TestState { totals(); }; - void testrun (bool b, string s) { + + void testrun (bool b, std::string s) { if (b) pass (s); else fail (s); } - void pass (string s) { + void pass (std::string s) { passed++; laststate = PASSED; lastmsg = s; - cout << "\t" << testout(PASSED) << s << endl; + std::cout << "\t" << testout(PASSED) << s << std::endl; } void pass (const char *c) { - string s = c; + std::string s = c; pass (s); } - void fail (string s) { + void fail (std::string s) { failed++; laststate = FAILED; lastmsg = s; - cout << "\t" << testout(FAILED) << s << endl; + std::cout << "\t" << testout(FAILED) << s << std::endl; } void fail (const char *c) { - string s = c; + std::string s = c; fail (s); } - void untested (string s) { + void untested (std::string s) { untest++; laststate = UNTESTED; lastmsg = s; - cout << "\t" << testout(UNTESTED) << s << endl; + std::cout << "\t" << testout(UNTESTED) << s << std::endl; } void untested (const char *c) { - string s = c; + std::string s = c; untested (s); } - void unresolved (string s) { + void unresolved (std::string s) { unresolve++; laststate = UNRESOLVED; lastmsg = s; - cout << "\t" << testout(UNRESOLVED) << s << endl; + std::cout << "\t" << testout(UNRESOLVED) << s << std::endl; } void unresolved (const char *c) { - string s = c; + std::string s = c; unresolved (s); } void totals (void) { - cout << "\t#passed:\t\t" << passed << endl; - cout << "\t#failed:\t\t" << failed << endl; + std::cout << "\t#passed:\t\t" << passed << std::endl; + std::cout << "\t#failed:\t\t" << failed << std::endl; if (untest) - cout << "\t#untested:\t\t" << untest << endl; + std::cout << "\t#untested:\t\t" << untest << std::endl; if (unresolve) - cout << "\t#unresolved:\t\t" << unresolve << endl; + std::cout << "\t#unresolved:\t\t" << unresolve << std::endl; } - // This is so thjis class can be printed in an ostream. - friend ostream & operator << (ostream &os, TestState& t) { + // This is so this class can be printed in an ostream. + friend std::ostream & operator << (std::ostream &os, TestState& t) { return os << "\t" << outstate[t.laststate] << t.lastmsg ; } int GetState(void) { return laststate; } - string GetMsg(void) { + std::string GetMsg(void) { return lastmsg; } }; diff --git a/testsuite/libdejagnu/unit.cc b/testsuite/libdejagnu/unit.cc index 9f070aa..6f3918a 100644 --- a/testsuite/libdejagnu/unit.cc +++ b/testsuite/libdejagnu/unit.cc @@ -1,13 +1,14 @@ // unit.cc -- This is a test case for the Dejagnu.h classes. #include -#include - #include #include #include #include #include +#include + +using namespace std; TestState runtest; TestState test; @@ -48,9 +49,12 @@ main (int argc, char *argv[]) { // Replace the output buffer for cout, so we can examine it to // see what was displayed. Otherwise, there is no way we can test // the logging functions completely. - streambuf *sb = cout.rdbuf(); char bbuuff[5120]; - sb->setbuf(bbuuff, 5120); +#ifdef HAVE_STL3 + cout.rdbuf()->pubsetbuf(bbuuff, 5120); +#else + cout.rdbuf()->setbuf(bbuuff, 5120); +#endif testClass1.tname = "testType1"; testClass1.tnum = 1; @@ -108,7 +112,6 @@ main (int argc, char *argv[]) { } else { runtest.fail ("Totals message"); } - }