From ed789c8a9bc2c66e3c314f82b47cc07c05b12f49 Mon Sep 17 00:00:00 2001 From: sf-mensch Date: Sun, 5 May 2024 20:48:04 +0000 Subject: [PATCH] Win32 fixes, mostly testcases --- cobc/error.c | 12 +-- libcob/common.c | 10 +- libcob/fileio.c | 6 +- tests/atlocal.in | 6 +- tests/testsuite.src/run_extensions.at | 13 ++- tests/testsuite.src/run_file.at | 57 ++++++----- tests/testsuite.src/run_misc.at | 140 ++++++++++++++++---------- tests/testsuite.src/used_binaries.at | 13 +-- 8 files changed, 163 insertions(+), 94 deletions(-) diff --git a/cobc/error.c b/cobc/error.c index 9c971d66e..4fa9314b7 100644 --- a/cobc/error.c +++ b/cobc/error.c @@ -74,19 +74,19 @@ print_error_prefix (const char *file, int line, const char *prefix) && file[0] != '\\' && file[1] != ':'){ int filelen = strlen (file); - int dirlen = 256; - char *cwd ; - absfile = cobc_malloc( dirlen + 1 + filelen + 1 ); + int dirlen = COB_MINI_BUFF; + char *cwd; + absfile = cobc_malloc (dirlen + 1 + filelen + 1); cwd = getcwd (absfile, dirlen); if (cwd != NULL ){ #ifdef HAVE_SYS_STAT_H struct stat st; #endif dirlen = strlen (cwd); - absfile[dirlen] = '/'; - memcpy (absfile+dirlen+1, file, filelen+1); + absfile[dirlen] = SLASH_CHAR; + memcpy (absfile + dirlen + 1, file, filelen + 1); #ifdef HAVE_SYS_STAT_H - if (!stat (absfile,&st)) + if (!stat (absfile, &st)) #endif { file = absfile; diff --git a/libcob/common.c b/libcob/common.c index 6f45b7564..c3d3dc7c1 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2012, 2014-2023 Free Software Foundation, Inc. + Copyright (C) 2001-2012, 2014-2024 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman This file is part of GnuCOBOL. @@ -21,6 +21,14 @@ #include "tarstamp.h" #include "config.h" +#ifdef __MINGW32__ +/* Is this needed for other environments as well? + We want to use all POSIX extensions possible. */ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112 +#endif +#endif + #include #include #include diff --git a/libcob/fileio.c b/libcob/fileio.c index ecb13dca7..d4c900f88 100644 --- a/libcob/fileio.c +++ b/libcob/fileio.c @@ -913,7 +913,7 @@ bdb_close_index (cob_file *f, int index) static int bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 -#if DB_VERSION_MAJOR >= 12 /* ABI break in BDB 12...) */ +#if DB_VERSION_MAJOR >= 6 /* ABI break in DB_VERSION_FAMILY 12 ... */ , size_t *locp #endif ) @@ -927,8 +927,8 @@ bdb_bt_compare (DB *db, const DBT *k1, const DBT *k2 cob_runtime_error ("bdb_bt_compare was given keys of different length"); } /* LCOV_EXCL_STOP */ -#if DB_VERSION_MAJOR >= 12 - locp = NULL; /* docs: must be set to NULL or corruption can occur ... */ +#if DB_VERSION_MAJOR >= 6 + locp = NULL; /* docs: must be set to NULL or corruption can occur ... */ #endif return indexed_key_compare (k1->data, k2->data, k2->size, col); } diff --git a/tests/atlocal.in b/tests/atlocal.in index 62fac6a25..3d49ec140 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -197,7 +197,11 @@ _unset_option () { # that doesn't match the one where the tested binaries were built # Note: not needed for running the testsuite with MSYS as this translates the path _return_path () { - echo "$1" + if test "x$MSYSTEM" = x; then + echo "$1" + else + cmd //c echo "$1" # note: we want forward slashes here | $SED 's|/|\\|g' + fi } # ensure we don't execute windows paths within programs generated by cygwin diff --git a/tests/testsuite.src/run_extensions.at b/tests/testsuite.src/run_extensions.at index e937044f8..cfa04244e 100644 --- a/tests/testsuite.src/run_extensions.at +++ b/tests/testsuite.src/run_extensions.at @@ -1,4 +1,4 @@ -## Copyright (C) 2003-2012, 2014-2023 Free Software Foundation, Inc. +## Copyright (C) 2003-2012, 2014-2024 Free Software Foundation, Inc. ## Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart, ## Ron Norman ## @@ -2220,6 +2220,9 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], +000000004 ], []) +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv callee.$COB_MODULE_EXT callee.old.$COB_MODULE_EXT]) + # no argument check leads to only check on use AT_CHECK([$COMPILE_MODULE -fno-ec=program-arg-mismatch callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [0], @@ -2231,6 +2234,8 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], +000000004 ], []) +AT_CHECK([mv callee.$COB_MODULE_EXT callee.nocheck.$COB_MODULE_EXT]) + # sticky linkage leads to only check on use AT_CHECK([$COMPILE_MODULE -fsticky-linkage callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [0], @@ -2242,6 +2247,8 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], +000000004 ], []) +AT_CHECK([mv callee.$COB_MODULE_EXT callee.stick.$COB_MODULE_EXT]) + AT_CHECK([$COMPILE_MODULE callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [1], [], [libcob: callee.cob:12: error: LINKAGE item X not passed by caller @@ -2641,6 +2648,10 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], [Hello, COBOL! Bye, COBOL-ENTRY! ]) + +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv hello.$COB_MODULE_EXT hello.old.$COB_MODULE_EXT]) + # no difference expected with sticky linkage (but other codegen) AT_CHECK([$COMPILE_MODULE -fentry-statement=ok -fsticky-linkage hello.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./caller], [0], diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index ed9351e01..0dd083262 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -46,10 +46,11 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 WSFS PIC X(2). PROCEDURE DIVISION. - * + OUT. OPEN EXTEND FILE-OPT IF WSFS NOT = "05" - DISPLAY "STATUS EXTEND, missing optional file:" WSFS. + DISPLAY "STATUS EXTEND, missing optional file:" WSFS + IF WSFS (1:1) NOT = "0" GO TO INP. MOVE ALL "A" TO FOREC WRITE FOREC IF WSFS NOT = "00" @@ -64,19 +65,22 @@ AT_DATA([prog.cob], [ WRITE F0REC IF WSFS NOT = "00" DISPLAY "STATUS WRITE B:" WSFS. - CLOSE FILE0 + CLOSE FILE0. * + INP. OPEN INPUT FILE-OPT IF WSFS NOT = "00" - DISPLAY "STATUS INPUT:" WSFS. + DISPLAY "STATUS INPUT:" WSFS + IF WSFS (1:1) NOT = "0" GO TO EX. READ FILE-OPT NEXT IF WSFS NOT = "00" DISPLAY "STATUS READ A:" WSFS. READ FILE-OPT NEXT IF WSFS NOT = "00" DISPLAY "STATUS READ B:" WSFS. - CLOSE FILE-OPT + CLOSE FILE-OPT. * + EX. STOP RUN. ]) @@ -110,10 +114,11 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 WSFS PIC X(2). PROCEDURE DIVISION. - * + OUT. OPEN OUTPUT FILE-TBL IF WSFS NOT = "00" - DISPLAY "STATUS OPEN OUTPUT:" WSFS. + DISPLAY "STATUS OPEN OUTPUT:" WSFS + IF WSFS (1:1) NOT = "0" GO TO INP. MOVE ALL "A" TO FOREC WRITE FOREC IF WSFS NOT = "00" @@ -121,6 +126,7 @@ AT_DATA([prog.cob], [ CLOSE FILE-TBL WITH LOCK IF WSFS NOT = "00" DISPLAY "STATUS CLOSE WITH LOCK:" WSFS. + INP. OPEN INPUT FILE-TBL IF WSFS NOT = "38" DISPLAY "STATUS INPUT after CLOSE LOCK:" WSFS. @@ -128,14 +134,17 @@ AT_DATA([prog.cob], [ IF WSFS NOT = "42" DISPLAY "STATUS CLOSE non-opened:" WSFS. * + DEL. * Note: MicroFocus _does_ delete the file and returns status 00 here DELETE FILE FILE-TBL IF WSFS NOT = "38" DISPLAY "STATUS DELETE FILE after CLOSE LOCK:" WSFS. * + INP2. OPEN INPUT FILE0 IF WSFS NOT = "00" - DISPLAY "STATUS INPUT separate file:" WSFS. + DISPLAY "STATUS INPUT separate file:" WSFS + IF WSFS (1:1) NOT = "0" GO TO EX. READ FILE0 NEXT IF WSFS NOT = "00" DISPLAY "STATUS READ A:" WSFS. @@ -145,6 +154,7 @@ AT_DATA([prog.cob], [ IF WSFS NOT = "00" DISPLAY "STATUS CLOSE:" WSFS. * + EX. STOP RUN. ]) @@ -173,10 +183,11 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 WSFS PIC X(2). PROCEDURE DIVISION. - * + MAIN. OPEN OUTPUT FILE-TBL IF WSFS NOT = "00" - DISPLAY "STATUS OPEN OUTPUT:" WSFS. + DISPLAY "STATUS OPEN OUTPUT:" WSFS + IF WSFS (1:1) NOT = "0" GOBACK. MOVE ALL "A" TO FOREC WRITE FOREC IF WSFS NOT = "00" @@ -1190,7 +1201,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). LOCAL-STORAGE SECTION. @@ -1230,7 +1241,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). LOCAL-STORAGE SECTION. @@ -1267,7 +1278,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). WORKING-STORAGE SECTION. @@ -1300,7 +1311,7 @@ AT_DATA([prog2.cob], [ ORGANIZATION LINE SEQUENTIAL FILE STATUS TEST-STAT. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). WORKING-STORAGE SECTION. @@ -1521,7 +1532,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN path ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). WORKING-STORAGE SECTION. @@ -1561,7 +1572,7 @@ AT_DATA([prog.cob], [ SELECT test-file ASSIGN fpath ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. - FILE SECTION. + FILE SECTION. FD test-file. 01 test-rec PIC X(5). PROCEDURE DIVISION. @@ -2343,7 +2354,7 @@ AT_DATA([prog.cob], [ record is varying in size from 107 to 362 characters depending on end-tbw-record - . + . 01 tbw-record. 02 tbw-key pic x(100). 02 tbw-alt. @@ -14383,8 +14394,8 @@ AT_DATA([prog1.cob], [ FD FILE2. 01 FS-FILE2 PIC X(10). WORKING-STORAGE SECTION. - 01 STAT-FILE1 PIC XX. - 01 STAT-FILE2 PIC XX. + 01 STAT-FILE1 PIC XX. + 01 STAT-FILE2 PIC XX. PROCEDURE DIVISION. DECLARATIVES. F-FILE1 SECTION. USE AFTER ERROR PROCEDURE ON FILE1. @@ -14401,7 +14412,7 @@ AT_DATA([prog1.cob], [ PROGRAMME SECTION. MAIN. OPEN INPUT FILE1 - OPEN INPUT FILE2. + OPEN INPUT FILE2. DISPLAY "READ FILE1". READ FILE1. DISPLAY "READ FILE2". @@ -14431,8 +14442,8 @@ AT_DATA([prog2.cob], [ FD FILE2. 01 FS-FILE2 PIC X(10). WORKING-STORAGE SECTION. - 01 STAT-FILE1 PIC XX. - 01 STAT-FILE2 PIC XX. + 01 STAT-FILE1 PIC XX. + 01 STAT-FILE2 PIC XX. PROCEDURE DIVISION. DECLARATIVES. F-FILE1 SECTION. USE AFTER ERROR PROCEDURE ON FILE1. @@ -14449,7 +14460,7 @@ AT_DATA([prog2.cob], [ PROGRAMME SECTION. MAIN. OPEN INPUT FILE1 - FILE2. + FILE2. DISPLAY "READ FILE1". READ FILE1. DISPLAY "READ FILE2". diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index 057f0ceb4..a1c8da6dc 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -394,10 +394,14 @@ AT_DATA([caller.cob], [ AT_CHECK([$COMPILE_MODULE callee.cob], [0], [], []) AT_CHECK([$COMPILE -o prog caller.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 1212 2312 3412], []) + +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv callee.$COB_MODULE_EXT callee.def.$COB_MODULE_EXT]) AT_CHECK([$COMPILE_MODULE -fdefaultbyte=0 callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 1111 2211 3311], []) # note: this is the tested MF result (INDEXED BY are USAGE COMP 9(08), 0-based !): +#AT_CHECK([mv callee.$COB_MODULE_EXT callee.zero.$COB_MODULE_EXT]) #AT_CHECK([$COMPILE_MODULE -std=mf-strict callee.cob], [0], [], []) #AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 1018 2117 3216], []) @@ -422,6 +426,7 @@ AT_DATA([callee.cob], [ ]) +AT_CHECK([mv callee.$COB_MODULE_EXT callee.old.$COB_MODULE_EXT]) AT_CHECK([$COMPILE_MODULE -std=acu-strict callee.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 19 20 31], []) # note: tested result with 2 byte: AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [ 15 26 37], []) @@ -7934,13 +7939,21 @@ Program-Id: caller Statement: AT END Line: 64 Program-Id: caller Statement: STOP RUN Line: 66 ]) +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv callee1.$COB_MODULE_EXT callee1.old.$COB_MODULE_EXT]) +AT_CHECK([mv callee2.$COB_MODULE_EXT callee2.old.$COB_MODULE_EXT]) +AT_CHECK([mv preload.$COB_MODULE_EXT preload.old.$COB_MODULE_EXT]) +AT_CHECK([mv preload2.$COB_MODULE_EXT preload2.old.$COB_MODULE_EXT]) +AT_CHECK([mv callee2c.$COB_MODULE_EXT callee2c.old.$COB_MODULE_EXT]) + + AT_CHECK([$COBC -ftraceall callee1.cob], [0], [], []) AT_CHECK([$COBC callee2.cob], [0], [], []) AT_CHECK([$COBC -ftrace -w preload.cob], [0], [], []) AT_CHECK([$COBC -ftraceall preload2.cob], [0], [], []) AT_CHECK([$COBC -fsource-location -w callee2c.cob], [0], [], []) -AT_CHECK([$COBC -x -o prog -ftraceall caller.cob], [0], [], []) -AT_CHECK([COB_PHYSICAL_CANCEL=1 COB_PRE_LOAD="preload"$PATHSEP"preload2" $COBCRUN_DIRECT ./prog], [0], [], +AT_CHECK([$COBC -x -o prognew -ftraceall caller.cob], [0], [], []) +AT_CHECK([COB_PHYSICAL_CANCEL=1 COB_PRE_LOAD="preload"$PATHSEP"preload2" $COBCRUN_DIRECT ./prognew], [0], [], [Source: 'caller.cob' Program-Id: caller Program-Id: caller MOVE Line: 15 @@ -14657,7 +14670,6 @@ AT_DATA([prog.cob], [ PARA-0007. STOP RUN. ]) -AT_CAPTURE_FILE([prof-prog.csv]) AT_CHECK([$COMPILE prog.cob], [0], [], [prog.cob: in section '1ST': @@ -14665,6 +14677,8 @@ prog.cob: in paragraph 'PARA-0003': prog.cob:11: warning: GO TO SECTION '2ND' ]) +AT_CAPTURE_FILE([prof-prog.csv]) + AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE='prof-$b.csv' $COBCRUN_DIRECT ./prog], [0], [], []) AT_CHECK([$COMPILE -fprof prog.cob], [0], [], @@ -14677,7 +14691,7 @@ AT_CHECK([COB_PROF_ENABLE=0 COB_PROF_FILE='prof-$b.csv' $COBCRUN_DIRECT ./prog], # Specific test for $f, which is an absolute file name AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE='$f-prof.csv' $COBCRUN_DIRECT ./prog], [0], [], [ignore]) -AT_CHECK([ls prog-prof.csv], [0], [ignore], []) +AT_CHECK([ls prog$COB_EXE_EXT-prof.csv], [0], [ignore], []) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE='prof-$$-$b.csv' COB_PROF_FORMAT=%i,%m,%s,%p,%e,%f,%l,%w,%k,%t,%h,%n,%x $COBCRUN_DIRECT ./prog], [0], [], [File prof-123456-prog.csv generated @@ -14714,10 +14728,10 @@ AT_DATA([prog.cob], [ DISPLAY "HELLO". DISPLAY "WORLD". ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog], [0], [HELLO WORLD ], @@ -14746,10 +14760,10 @@ AT_DATA([prog.cob], [ 2ND. DISPLAY "WORLD". ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog], [0], [HELLO WORLD ], @@ -14824,10 +14838,10 @@ AT_DATA([prog.cob], [ END PROGRAM inside-program. END PROGRAM prog. ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog], [0], [HELLO WORLD end iter @@ -14866,16 +14880,18 @@ AT_DATA([prog1.cob], [ 01 PARAM PIC 9. 01 CALL-NAME PIC X(10). PROCEDURE DIVISION. - MOVE 'prog2' TO CALL-NAME. - PERFORM CALL-PROG2 - VARYING COUNTER FROM 0 BY 1 - UNTIL COUNTER = 300. - GOBACK. + *>PROG. test the non-standard "no main paragraph, but + *> later using one" for its expected profiling output + MOVE 'prog2' TO CALL-NAME. + PERFORM CALL-PROG2 + VARYING COUNTER FROM 0 BY 1 + UNTIL COUNTER = 300. + GOBACK. CALL-PROG2. - MOVE 1 TO PARAM. - CALL "prog2" USING PARAM. - MOVE 2 TO PARAM. - CALL CALL-NAME USING PARAM. + MOVE 1 TO PARAM. + CALL "prog2" USING PARAM. + MOVE 2 TO PARAM. + CALL CALL-NAME USING PARAM. END PROGRAM prog1. ]) AT_DATA([prog2.cob], [ @@ -14886,21 +14902,20 @@ AT_DATA([prog2.cob], [ 01 PARAM PIC 9. PROCEDURE DIVISION USING PARAM. DISPLAYER SECTION. - IF PARAM = 1 - DISPLAY "X" NO ADVANCING - ELSE - PERFORM OTHER-DISPLAY. - GOBACK. + IF PARAM = 1 + DISPLAY "X" NO ADVANCING + ELSE + PERFORM OTHER-DISPLAY. + GOBACK. OTHER-DISPLAY SECTION. - DISPLAY "Y" NO ADVANCING. + DISPLAY "Y" NO ADVANCING. END PROGRAM prog2. ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE -fprof prog1.cob]) - AT_CHECK([$COMPILE_MODULE prog2.cob]) +AT_CAPTURE_FILE([prof.csv]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog1], [0], [XYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXYXY], [File prof.csv generated @@ -14909,13 +14924,15 @@ AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog1], [0] AT_CHECK([cat prof.csv], [0], [program-id,section,paragraph,entry,location,kind,time-ns,time,ncalls prog1,,,,prog1.cob:9,PROGRAM,1803000000,1.803 s,1 -prog1,MAIN SECTION,,,prog1.cob:10,SECTION,3301000000,3.301 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:10,PARAGRAPH,1801000000,1.801 s,1 -prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:15,PARAGRAPH,1500000000,1.500 s,300 -prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:17,CALL,300000000,0.300 s,300 -prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:19,CALL,300000000,0.300 s,300 +prog1,MAIN SECTION,,,prog1.cob:12,SECTION,3301000000,3.301 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:12,PARAGRAPH,1801000000,1.801 s,1 +prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:17,PARAGRAPH,1500000000,1.500 s,300 +prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:19,CALL,300000000,0.300 s,300 +prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:21,CALL,300000000,0.300 s,300 ]) +# same name sometimes leads to locks - especially on Win32 +AT_CHECK([mv prog2.$COB_MODULE_EXT prog2.old.$COB_MODULE_EXT]) AT_CHECK([$COMPILE_MODULE -fprof prog2.cob]) AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./prog1], [0], @@ -14931,11 +14948,11 @@ prog2,DISPLAYER,MAIN PARAGRAPH,,prog2.cob:8,PARAGRAPH,1200000000,1.200 s,600 prog2,OTHER-DISPLAY,,,prog2.cob:14,SECTION,300000000,0.300 s,300 prog2,OTHER-DISPLAY,MAIN PARAGRAPH,,prog2.cob:14,PARAGRAPH,300000000,0.300 s,300 prog1,,,,prog1.cob:9,PROGRAM,4803000000,4.803 s,1 -prog1,MAIN SECTION,,,prog1.cob:10,SECTION,9301000000,9.301 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:10,PARAGRAPH,4801000000,4.801 s,1 -prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:15,PARAGRAPH,4500000000,4.500 s,300 -prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:17,CALL,1500000000,1.500 s,300 -prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:19,CALL,2100000000,2.100 s,300 +prog1,MAIN SECTION,,,prog1.cob:12,SECTION,9301000000,9.301 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:12,PARAGRAPH,4801000000,4.801 s,1 +prog1,MAIN SECTION,CALL-PROG2,,prog1.cob:17,PARAGRAPH,4500000000,4.500 s,300 +prog1,MAIN SECTION,CALL-PROG2,prog2,prog1.cob:19,CALL,1500000000,1.500 s,300 +prog1,MAIN SECTION,CALL-PROG2,(dynamic),prog1.cob:21,CALL,2100000000,2.100 s,300 ]) AT_CLEANUP @@ -14948,39 +14965,54 @@ AT_DATA([prog1.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. prog1. DATA DIVISION. + working-storage section. + 1 os-check pic x(7). + 88 os-is-windows-or-dos values 'WINDOWS' 'FREEDOS'. + 78 callee value "./prog2". + 78 callee-wdos value ".\prog2". PROCEDURE DIVISION. - CALL "SYSTEM" USING "./prog2" - GOBACK. + accept os-check from environment "COB_ON_CYGWIN". + if os-check = spaces + accept os-check from environment "OS". + if os-check = spaces + accept os-check from environment "OS_NAME". + inspect os-check converting "werfdosin" to "WERFDOSIN". + if os-is-windows-or-dos + call "SYSTEM" using callee-wdos + else + call "SYSTEM" using callee. + GOBACK. ]) AT_DATA([prog2.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. prog2. PROCEDURE DIVISION. MAIN. - SET ENVIRONMENT "COB_PROF_FILE" TO "prof2.csv" - PERFORM PARA 5 TIMES. - GOBACK. + SET ENVIRONMENT "COB_PROF_FILE" TO "prof2.csv" + PERFORM PARA 5 TIMES. + GOBACK. PARA. - CONTINUE. + CONTINUE. ]) -AT_CAPTURE_FILE([prof1.csv]) -AT_CAPTURE_FILE([prof2.csv]) - AT_CHECK([$COMPILE_MODULE -fprof prog1.cob]) AT_CHECK([$COMPILE -fprof prog2.cob]) -AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof1.csv $COBCRUN ./prog1], [0], [], +AT_CAPTURE_FILE([prof1.csv]) +AT_CAPTURE_FILE([prof2.csv]) + +AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof1.csv $COBCRUN prog1], [0], [], [File prof2.csv generated File prof1.csv generated ]) AT_CHECK([cat prof1.csv], [0], [program-id,section,paragraph,entry,location,kind,time-ns,time,ncalls -prog1,,,,prog1.cob:5,PROGRAM,5000000,0.005 s,1 -prog1,MAIN SECTION,,,prog1.cob:6,SECTION,3000000,0.003 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:6,PARAGRAPH,3000000,0.003 s,1 -prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:6,CALL,1000000,0.001 s,1 +prog1,,,,prog1.cob:10,PROGRAM,5000000,0.005 s,1 +prog1,MAIN SECTION,,,prog1.cob:11,SECTION,3000000,0.003 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,,prog1.cob:11,PARAGRAPH,3000000,0.003 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:18,CALL,1000000,0.001 s,1 +prog1,MAIN SECTION,MAIN PARAGRAPH,SYSTEM,prog1.cob:20,CALL,0,0.000 s,0 ]) AT_CHECK([cat prof2.csv], [0], @@ -15030,16 +15062,18 @@ AT_DATA([callee.cob], [ PROGRAM-ID. callee. PROCEDURE DIVISION. MAIN. - PERFORM PARA 5 TIMES. - GOBACK. + PERFORM PARA 5 TIMES. + GOBACK. PARA. - CONTINUE. + CONTINUE. ]) -AT_CAPTURE_FILE([prof.csv]) AT_CHECK([$COMPILE caller.c]) AT_CHECK([$COMPILE_MODULE -fprof callee.cob]) -AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./caller], [0], [], [File prof.csv generated + +AT_CAPTURE_FILE([prof.csv]) +AT_CHECK([COB_PROF_ENABLE=1 COB_PROF_FILE=prof.csv $COBCRUN_DIRECT ./caller], [0], [], +[File prof.csv generated ]) AT_CLEANUP diff --git a/tests/testsuite.src/used_binaries.at b/tests/testsuite.src/used_binaries.at index 105c86137..118c45b85 100644 --- a/tests/testsuite.src/used_binaries.at +++ b/tests/testsuite.src/used_binaries.at @@ -1074,12 +1074,13 @@ AT_CHECK([$COBC -fdiagnostics-plain-output -fdiagnostics-show-caret -Wno-others AT_CHECK([$COMPILE -fdiagnostics-absolute-paths -Wall prog.cob 2> compiler.output], [1]) # note: -fdiagnostics-absolute-paths will show the realpath, -# so for MSYS/MSVC builds that will be x:\something\prog.cob -AT_CHECK([$SED -e "s|$(_return_path "$(pwd)/prog.cob")|DIR/prog.cob|" compiler.output], [0], +# so for MSYS/MSVC builds that will be x:\something\prog.cob, not the output of PWD, +# but the _return_path function from atlocal may adjust that +AT_CHECK([cat compiler.output | tr '\\' '/' | $SED "s|$(_return_path "$(pwd)")|DIR|"], [0], [DIR/prog.cob:7: error: CRUD.CPY: No such file or directory DIR/prog.cob:6: warning: numeric value is expected DIR/prog.cob:14: warning: ignoring redundant . -]) +], [], [echo set: $SED "s|$(_return_path "$(pwd)")|DIR|"]) AT_CLEANUP @@ -1127,11 +1128,11 @@ AT_CHECK([$COMPILE_MODULE --save-temps filec.c -o libfilec.$COB_MODULE_EXT], [0] # static build with correct function signature AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call prog2.cob], [0], [], [], [ # Previous test "failed" --> retry with import library - AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call -lfilec prog2.cob], [0], [], [])] + AT_CHECK([$COMPILE_MODULE --include $(_return_path "$(pwd)/filec.h") -fstatic-call -L. -lfilec prog2.cob], [0], ignore, ignore)] ) AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call prog2.cob -o prog2b], [0], [], [], [ # Previous test "failed" --> retry with import library - AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call -lfilec prog2.cob -o prog2b], [0], [], [])] + AT_CHECK([$COMPILE_MODULE -I . --include "filec.h" -fstatic-call -L. -lfilec prog2.cob -o prog2b], [0], ignore, ignore)] ) # We can use --copy to check a CALL against a prototype. However, this @@ -1156,7 +1157,7 @@ AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call prog2.co [prog2.cob:8: warning: unexpected RETURNING item ], [ # Previous test "failed" --> retry with import library - AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call -lfilec prog2.cob -o prog2c], [0], [], ignore)] + AT_CHECK([$COMPILE_MODULE -Wno-unfinished --copy "f.copy" -fstatic-call -L. -lfilec prog2.cob -o prog2c], [0], ignore, ignore)] ) AT_CLEANUP