Ignore:
Timestamp:
Mar 22, 2022, 1:11:41 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
8f01ad71
Parents:
14d5461
Message:

Made dumpable test much more agressive

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/meta/dumpable.cfa

    r14d5461 ra8e9e9d  
    1414//
    1515
     16#include <errno.h>
    1617#include <limits.h>
    17 #include <errno.h>
     18#include <string.h>
    1819
    1920#include <fstream.hfa>
    2021
    2122extern "C" {
     23        #include <fcntl.h>
     24        #include <unistd.h>
    2225        #include <sys/prctl.h>
    2326        #include <sys/resource.h>
    2427        #include <sys/statvfs.h>
    25         #include <unistd.h>
     28        #include <sys/stat.h>
     29        #include <sys/types.h>
    2630}
    2731
     
    102106}
    103107
     108void check_core_pattern() {
     109        int ret;
     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");
     113                return;
     114        }
     115
     116        try {
     117                const char * expected = "core";
     118                const int sz = sizeof("core");
     119                char buf[512];
     120                ret = read(cp, buf, 512);
     121                if(ret < 0) {
     122                        perror("first core pattern read error");
     123                        return;
     124                }
     125                if(strncmp(expected, buf, sz) != 0) {
     126                        serr | "/proc/sys/kernel/core_pattern does not contain 'core', was:" | nl | nl | buf | nl
     127                             | "Test script expect cores files to be dumped with name 'core' in current working directory." | nl
     128                             | "Apport is not supported, it should be deactivated in /etc/default/apport for the test suite to work with core dumps.";
     129
     130                        return;
     131                }
     132        }
     133        finally {
     134                ret = close(cp);
     135                if(ret < 0) perror("close(/proc/sys/kernel/core_pattern) error");
     136        }
     137
     138}
     139
    104140int main() {
    105141        check_ulimit();
     
    113149        check_dumpflag();
    114150
     151        check_core_pattern();
     152
    115153        sout | "Done";
    116154}
Note: See TracChangeset for help on using the changeset viewer.