CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
92 lines
3.3 KiB
Python
92 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
import libear
|
|
import libscanbuild.intercept as sut
|
|
import unittest
|
|
import os.path
|
|
|
|
|
|
class InterceptUtilTest(unittest.TestCase):
|
|
def test_format_entry_filters_action(self):
|
|
def test(command):
|
|
trace = {"command": command, "directory": "/opt/src/project"}
|
|
return list(sut.format_entry(trace))
|
|
|
|
self.assertTrue(test(["cc", "-c", "file.c", "-o", "file.o"]))
|
|
self.assertFalse(test(["cc", "-E", "file.c"]))
|
|
self.assertFalse(test(["cc", "-MM", "file.c"]))
|
|
self.assertFalse(test(["cc", "this.o", "that.o", "-o", "a.out"]))
|
|
|
|
def test_format_entry_normalize_filename(self):
|
|
parent = os.path.join(os.sep, "home", "me")
|
|
current = os.path.join(parent, "project")
|
|
|
|
def test(filename):
|
|
trace = {"directory": current, "command": ["cc", "-c", filename]}
|
|
return list(sut.format_entry(trace))[0]["file"]
|
|
|
|
self.assertEqual(os.path.join(current, "file.c"), test("file.c"))
|
|
self.assertEqual(os.path.join(current, "file.c"), test("./file.c"))
|
|
self.assertEqual(os.path.join(parent, "file.c"), test("../file.c"))
|
|
self.assertEqual(
|
|
os.path.join(current, "file.c"), test(os.path.join(current, "file.c"))
|
|
)
|
|
|
|
def test_sip(self):
|
|
def create_status_report(filename, message):
|
|
content = """#!/usr/bin/env sh
|
|
echo 'sa-la-la-la'
|
|
echo 'la-la-la'
|
|
echo '{0}'
|
|
echo 'sa-la-la-la'
|
|
echo 'la-la-la'
|
|
""".format(
|
|
message
|
|
)
|
|
lines = [line.strip() for line in content.split("\n")]
|
|
with open(filename, "w") as handle:
|
|
handle.write("\n".join(lines))
|
|
handle.close()
|
|
os.chmod(filename, 0x1FF)
|
|
|
|
def create_csrutil(dest_dir, status):
|
|
filename = os.path.join(dest_dir, "csrutil")
|
|
message = "System Integrity Protection status: {0}".format(status)
|
|
return create_status_report(filename, message)
|
|
|
|
def create_sestatus(dest_dir, status):
|
|
filename = os.path.join(dest_dir, "sestatus")
|
|
message = "SELinux status:\t{0}".format(status)
|
|
return create_status_report(filename, message)
|
|
|
|
ENABLED = "enabled"
|
|
DISABLED = "disabled"
|
|
|
|
OSX = "darwin"
|
|
|
|
with libear.TemporaryDirectory() as tmpdir:
|
|
saved = os.environ["PATH"]
|
|
try:
|
|
os.environ["PATH"] = tmpdir + ":" + saved
|
|
|
|
create_csrutil(tmpdir, ENABLED)
|
|
self.assertTrue(sut.is_preload_disabled(OSX))
|
|
|
|
create_csrutil(tmpdir, DISABLED)
|
|
self.assertFalse(sut.is_preload_disabled(OSX))
|
|
finally:
|
|
os.environ["PATH"] = saved
|
|
|
|
saved = os.environ["PATH"]
|
|
try:
|
|
os.environ["PATH"] = ""
|
|
# shall be false when it's not in the path
|
|
self.assertFalse(sut.is_preload_disabled(OSX))
|
|
|
|
self.assertFalse(sut.is_preload_disabled("unix"))
|
|
finally:
|
|
os.environ["PATH"] = saved
|