blob: 1d6665245026ccaace66e51396e6162179b2ab05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/config.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/util/exception.h>
#include <vespa/vespalib/process/process.h>
using namespace vespalib;
TEST("that uncaught exception causes negative exitcode.") {
Process proc("ulimit -c 0 && exec ./vespalib_caught_uncaught_app uncaught");
EXPECT_LESS(proc.join(), 0);
}
TEST("that uncaught silenced exception causes exitcode 66") {
Process proc("exec ./vespalib_caught_uncaught_app silenced_and_uncaught");
EXPECT_EQUAL(proc.join(), 66);
}
TEST("that caught silenced exception followed by an uncaught causes negative exitcode.") {
Process proc("ulimit -c 0 && exec ./vespalib_caught_uncaught_app uncaught_after_silenced_and_caught");
EXPECT_LESS(proc.join(), 0);
}
TEST("that caught silenced exception causes exitcode 0") {
Process proc("exec ./vespalib_caught_uncaught_app silenced_and_caught");
EXPECT_EQUAL(proc.join(), 0);
}
#ifndef VESPA_USE_SANITIZER
#ifdef __APPLE__
// setrlimit with RLIMIT_AS is broken on Darwin
#else
TEST("that mmap within limits are fine cause exitcode 0") {
Process proc("exec ./vespalib_mmap_app 536870912 10485760 1");
EXPECT_EQUAL(proc.join(), 0);
}
TEST("that mmap beyond limits cause negative exitcode.") {
Process proc("ulimit -c 0 && exec ./vespalib_mmap_app 100000000 10485760 10");
EXPECT_LESS(proc.join(), 0);
}
TEST("that mmap beyond limits with set VESPA_SILENCE_CORE_ON_OOM cause exitcode 66.") {
Process proc("VESPA_SILENCE_CORE_ON_OOM=1 exec ./vespalib_mmap_app 100000000 10485760 10");
EXPECT_EQUAL(proc.join(), 66);
}
#endif
#endif
TEST_MAIN() { TEST_RUN_ALL(); }
|