aboutsummaryrefslogtreecommitdiff
path: root/infra/cifuzz
diff options
context:
space:
mode:
Diffstat (limited to 'infra/cifuzz')
-rw-r--r--infra/cifuzz/cifuzz_end_to_end_test.py47
-rw-r--r--infra/cifuzz/run_cifuzz.py5
2 files changed, 51 insertions, 1 deletions
diff --git a/infra/cifuzz/cifuzz_end_to_end_test.py b/infra/cifuzz/cifuzz_end_to_end_test.py
new file mode 100644
index 000000000..3a443dd54
--- /dev/null
+++ b/infra/cifuzz/cifuzz_end_to_end_test.py
@@ -0,0 +1,47 @@
+# Copyright 2021 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""End-to-End tests for CIFuzz."""
+import os
+import tempfile
+import unittest
+
+import run_cifuzz
+import test_helpers
+
+CIFUZZ_DIR = os.path.dirname(os.path.abspath(__file__))
+EXTERNAL_PROJECT_PATH = os.path.join(CIFUZZ_DIR, 'test_data',
+ 'external-project')
+
+
+# This test will fail if not run as root because the fuzzer build process
+# creates binaries that only root can write to.
+# Use a seperate env var to keep this seperate from integration tests which
+# don't have this annoying property.
+@unittest.skipIf(not os.getenv('END_TO_END_TESTS'),
+ 'END_TO_END_TESTS=1 not set')
+class EndToEndTest(unittest.TestCase):
+ """End-to-End tests for CIFuzz."""
+
+ def setUp(self):
+ test_helpers.patch_environ(self)
+
+ def test_simple(self):
+ """Simple end-to-end test using run_cifuzz.main()."""
+ os.environ['REPOSITORY'] = 'external-project'
+ os.environ['PROJECT_SRC_PATH'] = EXTERNAL_PROJECT_PATH
+ os.environ['BUILD_INTEGRATION_PATH'] = 'cifuzz-build-integration'
+ with tempfile.TemporaryDirectory() as temp_dir:
+ os.environ['WORKSPACE'] = temp_dir
+ # TODO(metzman): Verify the crash, affected fuzzers and other things.
+ self.assertEqual(run_cifuzz.main(), 1)
diff --git a/infra/cifuzz/run_cifuzz.py b/infra/cifuzz/run_cifuzz.py
index bd0e907da..c68a5de03 100644
--- a/infra/cifuzz/run_cifuzz.py
+++ b/infra/cifuzz/run_cifuzz.py
@@ -15,6 +15,7 @@
docker image. This cannot depend on any CIFuzz code or third party packages."""
import os
import subprocess
+import sys
import tempfile
import logging
@@ -83,7 +84,9 @@ def main():
docker_run('run_fuzzers', workdir, project_src_path)
except subprocess.CalledProcessError:
logging.error('run_fuzzers failed.')
+ return 1
+ return 0
if __name__ == '__main__':
- main()
+ sys.exit(main())