Changes in / [18d7aaf:d68a3f7]
- Files:
-
- 4 edited
-
Makefile.am (modified) (3 diffs)
-
configure.ac (modified) (2 diffs)
-
tests/meta/dumpable.cfa (modified) (4 diffs)
-
tests/time.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r18d7aaf rd68a3f7 11 11 ## Created On : Sun May 31 22:14:18 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Fri Jul 19 16:15:24202414 ## Update Count : 5 813 ## Last Modified On : Tue Jul 16 16:59:12 2024 14 ## Update Count : 57 15 15 ############################################################################### 16 16 … … 22 22 23 23 SUBDIRS = driver src . @LIBCFA_TARGET_DIRS@ 24 DIST_SUBDIRS = driver src . libcfa tests tools/prettyprinter24 DIST_SUBDIRS = driver src . libcfa tests 25 25 26 26 @LIBCFA_TARGET_MAKEFILES@ : Makefile ${srcdir}/libcfa/configure … … 35 35 man1_MANS = doc/man/cfa.1 36 36 37 EXTRA_DIST = LICENSE doc/man/cfa.1 libcfa/configure libcfa/Makefile.dist.am libcfa/Makefile.dist.in tools/build/distcc_hash tools/build/push2dist.sh 37 EXTRA_DIST = LICENSE doc/man/cfa.1 libcfa/configure libcfa/Makefile.dist.am libcfa/Makefile.dist.in tools/build/distcc_hash tools/build/push2dist.sh tools/prettyprinter 38 38 39 39 debug ?= yes -
configure.ac
r18d7aaf rd68a3f7 273 273 libcfa/Makefile:libcfa/Makefile.dist.in 274 274 tests/Makefile 275 tools/prettyprinter/Makefile276 275 ]) 277 276 … … 284 283 benchmark/io/http/Makefile 285 284 tools/Makefile 285 tools/prettyprinter/Makefile 286 286 benchmark/Cargo.toml 287 287 ]) -
tests/meta/dumpable.cfa
r18d7aaf rd68a3f7 9 9 // Author : Thierry Delisle 10 10 // Created On : Wed Jan 05 13:53:22 2022 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 19 07:58:45 202413 // Update Count : 1011 // Last Modified By : 12 // Last Modified On : 13 // Update Count : 14 14 // 15 15 … … 17 17 #include <limits.h> 18 18 #include <string.h> 19 #include <unistd.h>20 19 21 20 #include <fstream.hfa> … … 23 22 extern "C" { 24 23 #include <fcntl.h> 24 #include <unistd.h> 25 25 #include <sys/prctl.h> 26 26 #include <sys/resource.h> … … 32 32 void check_ulimit() { 33 33 struct rlimit rlp; 34 getrlimit( RLIMIT_CORE, &rlp);35 if ( rlp.rlim_cur < 536870912) {34 getrlimit(RLIMIT_CORE, &rlp); 35 if(rlp.rlim_cur < 536870912) { 36 36 serr | "Soft core limit is less than ~500Mb: " | rlp.rlim_cur; 37 } // if37 } 38 38 39 if ( rlp.rlim_max < 536870912) {39 if(rlp.rlim_max < 536870912) { 40 40 serr | "Hard core limit is less than ~500Mb: " | rlp.rlim_max; 41 } // if41 } 42 42 } 43 43 44 44 void check_permission() { 45 char myExe[PATH_MAX]; 46 ssize_t n = readlink( "/proc/self/exe", myExe, sizeof(myExe)); 47 if ( n < 0 ) { 48 perror( "readlink(/proc/self/exe ) error" ); 49 return 1; 50 } // if 51 myExe[n] = '\0'; 45 { 46 char myExe[PATH_MAX]; 47 ssize_t n = readlink("/proc/self/exe", myExe, sizeof(myExe)); 48 if (n < 0) { 49 perror("readlink(/proc/self/exe) error"); 50 return 1; 51 } 52 myExe[n] = '\0'; 52 53 53 if ( int r = access( myExe, F_OK ); r != 0 ) serr | "Expected current executable does not exist!" | r | errno; 54 if ( int r = access( myExe, R_OK ); r != 0 ) serr | "No read access for current executable" | r | errno; 54 if(int r = access(myExe, F_OK); r != 0) serr | "Expected current executable does not exist!" | r | errno; 55 if(int r = access(myExe, R_OK); r != 0) serr | "No read access for current executable" | r | errno; 56 } 55 57 56 char myCwd[PATH_MAX]; 57 if ( getcwd( myCwd, sizeof(myCwd ) ) == 0p ) { 58 perror( "getcwd() error" ); 59 return; 60 } // if 58 { 59 char myCwd[PATH_MAX]; 60 if (getcwd(myCwd, sizeof(myCwd)) == 0p) { 61 perror("getcwd() error"); 62 return; 63 } 61 64 62 if ( access( myCwd, F_OK ) != 0 ) serr | "Expected current working directory does not exist!"; 63 if ( access( myCwd, R_OK ) != 0 ) serr | "No read access for current working directory"; 64 if ( access( myCwd, W_OK ) != 0 ) serr | "No write access for current working directory"; 65 if(access(myCwd, F_OK) != 0) serr | "Expected current working directory does not exist!"; 66 if(access(myCwd, R_OK) != 0) serr | "No read access for current working directory"; 67 if(access(myCwd, W_OK) != 0) serr | "No write access for current working directory"; 68 } 65 69 } 66 70 67 71 void check_free_space() { 68 72 struct statvfs buf; 69 if ( statvfs( ".", &buf ) != 0) {70 perror( "statvfs() error");73 if(statvfs(".", &buf) != 0) { 74 perror("statvfs() error"); 71 75 return; 72 } // if76 } 73 77 74 78 uint64_t avail = buf.f_bavail; 75 79 avail *= buf.f_bsize; 76 if ( avail < 536870912_l64u) {80 if(avail < 536870912_l64u) { 77 81 serr | "Available diskspace is less than ~500Mb: " | avail; 78 } // if82 } 79 83 80 if ( buf.f_favail < 10) {84 if(buf.f_favail < 10) { 81 85 serr | "Available inodes is less than 10: " | buf.f_favail; 82 } // if86 } 83 87 84 if ( buf.f_flag & ST_RDONLY) {88 if(buf.f_flag & ST_RDONLY) { 85 89 serr | "Filesystem is read only"; 86 } // if90 } 87 91 } 88 92 89 93 void check_noconflict() { 90 c onst char * name = "./core";91 if ( access( name, F_OK ) == 0 ) serr | "File \"" | name | "\"already exists";94 char * name = "./core"; 95 if(access("./core", F_OK) == 0) serr | "A file of the core name ('" | name | "') already exists"; 92 96 } 93 97 94 98 void check_dumpflag() { 95 int r = prctl( PR_GET_DUMPABLE, 0, 0, 0, 0);96 if ( r < 0) {97 perror( "prctl( PR_GET_DUMPABLE ) error");99 int r = prctl(PR_GET_DUMPABLE, 0, 0, 0, 0); 100 if(r < 0) { 101 perror("prctl(PR_GET_DUMPABLE) error"); 98 102 return; 99 } // if103 } 100 104 101 if ( r != 1 ) serr | "dumpable attribute not set to 1 \"( SUID_DUMP_USER, process is dumpable)\", was" | r;105 if(r != 1) serr | "dumpable attribute not set to 1 \"(SUID_DUMP_USER, process is dumpable)\", was" | r; 102 106 } 103 107 104 108 void check_core_pattern() { 105 109 int ret; 106 int cp = open( "/proc/sys/kernel/core_pattern", 0, O_RDONLY ); 107 108 if ( cp < 0 ) { 109 perror( "open(/proc/sys/kernel/core_pattern, O_RDONLY ) error" ); 110 int cp = open("/proc/sys/kernel/core_pattern", 0, O_RDONLY); 111 if(cp < 0) { 112 perror("open(/proc/sys/kernel/core_pattern, O_RDONLY) error"); 110 113 return; 111 } // if114 } 112 115 113 116 try { 114 117 const char * expected = "core\n"; 115 const int sz = sizeof( "core\n");118 const int sz = sizeof("core\n"); 116 119 char buf[512]; 117 ret = read( cp, buf, 512);118 if ( ret < 0) {119 perror( "core pattern read error");120 ret = read(cp, buf, 512); 121 if(ret < 0) { 122 perror("first core pattern read error"); 120 123 return; 121 } // if 124 } 125 ret = strncmp(expected, buf, sz - 1); 126 if(ret != 0) { 127 serr | "/proc/sys/kernel/core_pattern does not contain 'core', was:" | nl | nl | buf | nl 128 | "Test script expect cores files to be dumped with name 'core' in current working directory." | nl 129 | "Apport is not supported, it should be deactivated in /etc/default/apport for the test suite to work with core dumps."; 122 130 123 ret = strncmp( expected, buf, sz - 1 ); 124 if ( ret != 0 ) { 125 serr | "Apport is supported on your system, which means the test-suite core-dump feature does not work." | nl 126 | "This is not a test failure, just a limitation on debugging output should a test fail."; 127 } // if 128 } finally { 129 ret = close( cp ); 130 if ( ret < 0 ) perror( "close( /proc/sys/kernel/core_pattern ) error" ); 131 } // try 131 return; 132 } 133 } 134 finally { 135 ret = close(cp); 136 if(ret < 0) perror("close(/proc/sys/kernel/core_pattern) error"); 137 } 138 132 139 } 133 140 134 141 int main() { 135 142 check_ulimit(); 143 136 144 check_permission(); 145 137 146 check_free_space(); 147 138 148 check_noconflict(); 149 139 150 check_dumpflag(); 151 140 152 check_core_pattern(); 153 141 154 sout | "Done"; 142 155 } -
tests/time.cfa
r18d7aaf rd68a3f7 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 19 08:06:59202413 // Update Count : 7512 // Last Modified On : Thu Jul 18 21:56:01 2024 13 // Update Count : 64 14 14 // 15 15 … … 18 18 #include <stdlib.h> // putenv 19 19 20 extern "C" size_t malloc_unfreed() { return 1024; } // guess at unfreed storage from putenv20 extern "C" size_t malloc_unfreed() { return 337; } // unfreed storage from tzset 21 21 22 22 int main() { 23 23 // Set fixed time location to obtain repeatable output where ever run. 24 putenv( "TZ=America/Toronto" ); // set fixed time zone 25 // tzset has the stupidest interface I have ever seen. 24 putenv("TZ=America/Toronto"); // set fixed time zone 26 25 tzset(); // set time zone 27 26 … … 82 81 sout | buf; 83 82 } // main 83 84 // Local Variables: // 85 // mode: c // 86 // tab-width: 4 // 87 // compile-command: "cfa time.cfa" // 88 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.