summaryrefslogtreecommitdiff
path: root/jstests/selinux/core.js
blob: 1037018be81e791e6933155ce09bb148b3d7f783 (plain)
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
54
55
56
57
58

'use strict';

load('jstests/selinux/lib/selinux_base_test.js');

class TestDefinition extends SelinuxBaseTest {
    async run() {
        // On RHEL7 there is no python3, but check_has_tag.py will also work with python2
        const python = (0 == runNonMongoProgram("which", "python3")) ? "python3" : "python2";

        const dirs = ["jstests/core", "jstests/core_standalone"];

        for (let dir of dirs) {
            jsTest.log("Running tests in " + dir);

            const all_tests = ls(dir).filter(d => !d.endsWith("/")).sort();
            assert(all_tests);
            assert(all_tests.length);

            for (let t of all_tests) {
                // Tests in jstests/core weren't specifically made to pass in this very scenario, so
                // we will not be fixing what is not working, and instead exclude them from running
                // as "known" to not work. This is done by the means of "no_selinux" tag
                const HAS_TAG = 0;
                if (HAS_TAG ==
                    runNonMongoProgram(python,
                                       "buildscripts/resmokelib/utils/check_has_tag.py",
                                       t,
                                       "^no_selinux$")) {
                    jsTest.log("Skipping test due to no_selinux tag: " + t);
                    continue;
                }

                // Tests relying on featureFlagXXX will not work
                if (HAS_TAG ==
                    runNonMongoProgram(python,
                                       "buildscripts/resmokelib/utils/check_has_tag.py",
                                       t,
                                       "^featureFlag.+$")) {
                    jsTest.log("Skipping test due to feature flag tag: " + t);
                    continue;
                }

                jsTest.log("Running test: " + t);
                try {
                    await import(t);
                } catch (e) {
                    print(tojson(e));
                    throw ("failed to load test " + t);
                }

                jsTest.log("Successful test: " + t);
            }
        }

        jsTest.log("code test suite ran successfully");
    }
}