diff options
| author | Akaps316 <[email protected]> | 2026-04-05 10:58:30 +0530 |
|---|---|---|
| committer | Akaps316 <[email protected]> | 2026-04-05 10:58:30 +0530 |
| commit | 9b189a6f1098e55c4ea6d1928644bed4acf5a412 (patch) | |
| tree | 24c57eb099605c9b10e322fdf648f2ba96d4886e /tests | |
| parent | d0f83e55778e37afc767cf8fa382e16d6e5dc001 (diff) | |
| parent | 95e7d1658cb820accdc1bea5c79562331be9baf7 (diff) | |
fix(xcode.application): resolve merge conflict with upstream dev
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/projects/c/filc/safety_test/src/main.c | 17 | ||||
| -rw-r--r-- | tests/projects/c/filc/safety_test/test.lua | 52 | ||||
| -rw-r--r-- | tests/projects/c/filc/safety_test/xmake.lua | 9 | ||||
| -rw-r--r-- | tests/projects/objc/macapp_duplicate_rpath/src/Info.plist | 18 | ||||
| -rw-r--r-- | tests/projects/objc/macapp_duplicate_rpath/src/main.m | 5 | ||||
| -rw-r--r-- | tests/projects/objc/macapp_duplicate_rpath/test.lua | 8 | ||||
| -rw-r--r-- | tests/projects/objc/macapp_duplicate_rpath/xmake.lua | 9 |
7 files changed, 118 insertions, 0 deletions
diff --git a/tests/projects/c/filc/safety_test/src/main.c b/tests/projects/c/filc/safety_test/src/main.c new file mode 100644 index 000000000..d23718c3e --- /dev/null +++ b/tests/projects/c/filc/safety_test/src/main.c @@ -0,0 +1,17 @@ +/* Test that filc catches calling a function pointer with a wrong address. + * + * Expected runtime output (exit non-zero): + * filc safety error: cannot access pointer as function with ptr != aux ... + * filc panic: thwarted a futile attempt to violate memory safety. + */ +#include <stdfil.h> +#include <stdlib.h> + +static void foo(void) { +} + +int main() { + void (*my_foo)(void) = (void(*)(void))((char*)foo + 42); + my_foo(); + return 0; +} diff --git a/tests/projects/c/filc/safety_test/test.lua b/tests/projects/c/filc/safety_test/test.lua new file mode 100644 index 000000000..2a372b3cd --- /dev/null +++ b/tests/projects/c/filc/safety_test/test.lua @@ -0,0 +1,52 @@ +import("utils.ci.is_running", {alias = "ci_is_running"}) + +function main(t) + -- filc only supports Linux x86_64 + if os.host() ~= "linux" or os.arch() ~= "x86_64" then + return t:skip("filc is only supported on linux/x86_64") + end + + local flags = ci_is_running() and "-vD" or "" + + -- configure and install the filc package; skip if unavailable + local configured = try + { + function () + os.exec("xmake f -c -y " .. flags) + return true + end, + catch { function () end } + } + if not configured then + return t:skip("filc package not available or install failed") + end + + os.exec("xmake -r " .. flags) + + -- find the compiled binary + local binfile = path.join("build", os.host(), os.arch(), "release", "safety_test") + assert(os.isfile(binfile), "binary not found: " .. binfile) + + -- run the binary — it MUST exit non-zero and emit a filc safety error + -- os.iorunv raises on non-zero exit in the sandbox, so catch the failure + local filc_output = nil + try + { + function () + os.iorunv(binfile, {}) + end, + catch + { + function (errors) + filc_output = tostring(errors) + end + } + } + assert(filc_output, "expected safety_test to exit non-zero, but it succeeded") + assert(filc_output:find("filc safety error", 1, true), + "expected 'filc safety error' in output, got:\n" .. filc_output) + assert(filc_output:find("filc panic", 1, true), + "expected 'filc panic' in output, got:\n" .. filc_output) + + cprint("${green}filc safety check triggered as expected${reset}") +end diff --git a/tests/projects/c/filc/safety_test/xmake.lua b/tests/projects/c/filc/safety_test/xmake.lua new file mode 100644 index 000000000..4ebbf9792 --- /dev/null +++ b/tests/projects/c/filc/safety_test/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") + +add_requires("filc") + +target("safety_test") + set_kind("binary") + set_toolchains("@filc") + add_packages("filc") + add_files("src/*.c") diff --git a/tests/projects/objc/macapp_duplicate_rpath/src/Info.plist b/tests/projects/objc/macapp_duplicate_rpath/src/Info.plist new file mode 100644 index 000000000..e20952d73 --- /dev/null +++ b/tests/projects/objc/macapp_duplicate_rpath/src/Info.plist @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleExecutable</key> + <string>demo</string> + <key>CFBundleIdentifier</key> + <string>io.xmake.demo.duprpath</string> + <key>CFBundleName</key> + <string>demo</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleVersion</key> + <string>1</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> +</dict> +</plist> diff --git a/tests/projects/objc/macapp_duplicate_rpath/src/main.m b/tests/projects/objc/macapp_duplicate_rpath/src/main.m new file mode 100644 index 000000000..f481d2909 --- /dev/null +++ b/tests/projects/objc/macapp_duplicate_rpath/src/main.m @@ -0,0 +1,5 @@ +#import <AppKit/AppKit.h> + +int main(void) { + return 0; +} diff --git a/tests/projects/objc/macapp_duplicate_rpath/test.lua b/tests/projects/objc/macapp_duplicate_rpath/test.lua new file mode 100644 index 000000000..561d206cf --- /dev/null +++ b/tests/projects/objc/macapp_duplicate_rpath/test.lua @@ -0,0 +1,8 @@ +function main(t) + if not is_host("macosx") then + return t:skip("wrong host platform") + end + + os.execv("xmake", {"f", "-p", "macosx", "-a", os.arch(), "-c"}) + os.execv("xmake", {"-vD"}) +end diff --git a/tests/projects/objc/macapp_duplicate_rpath/xmake.lua b/tests/projects/objc/macapp_duplicate_rpath/xmake.lua new file mode 100644 index 000000000..a9428203f --- /dev/null +++ b/tests/projects/objc/macapp_duplicate_rpath/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.release", "mode.debug") + +set_languages("c11", "objc") + +target("demo") + add_rules("xcode.application") + add_rpathdirs("@executable_path/../Frameworks") + add_files("src/main.m") + add_files("src/Info.plist") |
