Skip to content

Commit 03f7ebc

Browse files
committed
test/CMakeLists.txt: run Embedded Swift for Wasm tests
Run new `check-swift-embedded-wasi` target from `test/CMakeLists.txt`, tweak `lit.cfg` to support both `-wasi` and `-wasip1` triples, exclude unsupported tests based on `CPU=wasm32` instead of `OS=wasi`.
1 parent 792f4f3 commit 03f7ebc

20 files changed

+63
-36
lines changed

test/CMakeLists.txt

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,44 @@ foreach(SDK ${SWIFT_SDKS})
587587
PROPERTY FOLDER "Tests/check-swift")
588588
endforeach()
589589
endforeach()
590+
591+
if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING AND (${ARCH} STREQUAL "wasm32"))
592+
set(test_mode "optimize_none")
593+
set(test_subset "primary")
594+
set(VARIANT_SUFFIX "-embedded-wasi")
595+
set(VARIANT_TRIPLE "wasm32-unknown-wasip1")
596+
set(test_bin_dir "${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/embedded")
597+
set(VARIANT_EXTERNAL_EMBEDDED_PLATFORM FALSE)
598+
set(VARIANT_EXTERNAL_EMBEDDED_DEVICE)
599+
set(SWIFT_TEST_RESULTS_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/swift-test-results/${VARIANT_TRIPLE}")
600+
swift_configure_lit_site_cfg(
601+
"${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in"
602+
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.site.cfg"
603+
"test${VARIANT_SUFFIX}.lit.site.cfg")
604+
swift_generate_lit_swift_features_cfg("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.swift-features.cfg")
605+
606+
set(test_target_name
607+
"check-swift${VARIANT_SUFFIX}")
608+
set(directories "${test_bin_dir}")
609+
610+
set(embedded_wasm_lit_args)
611+
setup_lit_args(embedded_wasm_lit_args "${SDK}" "${SWIFT_TEST_RESULTS_DIR}" "${SWIFTLIB_DIR}")
612+
613+
add_custom_target("${test_target_name}"
614+
${maybe_command_upload_stdlib}
615+
${command_upload_swift_reflection_test}
616+
${command_clean_test_results_dir}
617+
COMMAND
618+
${CMAKE_COMMAND} -E env ${SWIFT_LIT_ENVIRONMENT}
619+
$<TARGET_FILE:Python3::Interpreter> "${LIT}"
620+
${embedded_wasm_lit_args}
621+
"--param" "swift_test_subset=${test_subset}"
622+
"--param" "swift_test_mode=${test_mode}"
623+
${directories}
624+
DEPENDS ${dependencies}
625+
COMMENT "Running ${test_subset} Swift tests for ${VARIANT_TRIPLE}"
626+
USES_TERMINAL)
627+
endif()
590628
endforeach()
591629
endforeach()
592630
endforeach()
@@ -624,17 +662,6 @@ if(SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING)
624662
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.site.cfg"
625663
"test${VARIANT_SUFFIX}.lit.site.cfg")
626664
swift_generate_lit_swift_features_cfg("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.swift-features.cfg")
627-
628-
set(VARIANT_SUFFIX "-embedded-wasi")
629-
set(VARIANT_TRIPLE "wasm32-unknown-wasip1")
630-
set(VARIANT_EXTERNAL_EMBEDDED_PLATFORM FALSE)
631-
set(VARIANT_EXTERNAL_EMBEDDED_DEVICE)
632-
set(SWIFT_TEST_RESULTS_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/swift-test-results/${VARIANT_TRIPLE}")
633-
swift_configure_lit_site_cfg(
634-
"${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in"
635-
"${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.site.cfg"
636-
"test${VARIANT_SUFFIX}.lit.site.cfg")
637-
swift_generate_lit_swift_features_cfg("${CMAKE_CURRENT_BINARY_DIR}${VARIANT_SUFFIX}/lit.swift-features.cfg")
638665
endif()
639666

640667
# Add shortcuts for the default variant.

test/embedded/builtin-float.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// RUN: %target-swift-frontend -target armv7em-none-none-eabi -emit-ir %t/Main.swift -enable-experimental-feature Embedded -module-cache-path %t/ModuleCache -Xcc -I%t/include
66

7-
// UNSUPPORTED: OS=wasi
7+
// UNSUPPORTED: CPU=wasm32
88
// REQUIRES: swift_in_compiler
99
// REQUIRES: optimized_stdlib
1010
// REQUIRES: CODEGENERATOR=ARM

test/embedded/dependencies-random.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt
55

66
// Linux/ELF and Wasm don't use the "_" prefix in symbol mangling.
7-
// RUN: if [ %target-os == "linux-gnu" ] || [ %target-os == "wasi" ]; then sed -E -i -e 's/^_(.*)$/\1/' %t/allowed-dependencies.txt; fi
7+
// RUN: if [ %target-os == "linux-gnu" ] || [[ %target-os =~ "wasi" ]]; then sed -E -i -e 's/^_(.*)$/\1/' %t/allowed-dependencies.txt; fi
88

99
// Wasm has additional dependencies
10-
// RUN: if [ %target-os == "wasi" ]; then ex -sc '3i|__stack_pointer' -sc '1i|__memory_base' -sc '1i|__indirect_function_table' -cx %t/allowed-dependencies.txt; fi
10+
// RUN: if [[ %target-os =~ "wasi" ]]; then ex -sc '3i|__stack_pointer' -sc '1i|__memory_base' -sc '1i|__indirect_function_table' -cx %t/allowed-dependencies.txt; fi
1111

1212
// RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt
1313

test/embedded/float-abi-hard.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: %target-swift-emit-ir %t/Main.swift -import-bridging-header %t/BridgingHeader.h -parse-as-library -enable-experimental-feature Embedded -wmo \
55
// RUN: -target armv7em-none-none-eabi -Xcc -mthumb -Xcc -mcpu=cortex-m7 -Xcc -mfloat-abi=hard -Xcc -mfpu=fpv5-sp-d16 -Xcc -D__FPU_USED=1 -Xcc -falign-functions=16
66

7-
// UNSUPPORTED: OS=wasi
7+
// UNSUPPORTED: CPU=wasm32
88
// REQUIRES: swift_in_compiler
99
// REQUIRES: optimized_stdlib
1010
// REQUIRES: CODEGENERATOR=ARM

test/embedded/fragile-reference.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -target armv7-apple-none-macho -module-name main -parse-as-library -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
22
// RUN: %target-swift-frontend -target arm64-apple-none-macho -module-name main -parse-as-library -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
33

4-
// UNSUPPORTED: OS=wasi
4+
// UNSUPPORTED: CPU=wasm32
55
// REQUIRES: swift_in_compiler
66
// REQUIRES: CODEGENERATOR=ARM
77
// REQUIRES: embedded_stdlib_cross_compiling

test/embedded/no-allocations-print.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %target-swift-emit-ir -target armv7-apple-none-macho -no-allocations %s -enable-experimental-feature Embedded
44
// RUN: %target-swift-emit-ir -target arm64-apple-none-macho -no-allocations %s -enable-experimental-feature Embedded
55

6-
// UNSUPPORTED: OS=wasi
6+
// UNSUPPORTED: CPU=wasm32
77
// REQUIRES: swift_in_compiler
88
// REQUIRES: optimized_stdlib
99
// REQUIRES: CODEGENERATOR=ARM

test/embedded/optionset2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
22
// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
33

4-
// UNSUPPORTED: OS=wasi
4+
// UNSUPPORTED: CPU=wasm32
55
// REQUIRES: swift_in_compiler
66
// REQUIRES: optimized_stdlib
77
// REQUIRES: CODEGENERATOR=ARM

test/embedded/ouroboros-bug.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// RUN: %target-swift-frontend -target armv7-apple-none-macho -assert-config Debug -Osize -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
77
// RUN: %target-swift-frontend -target arm64-apple-none-macho -assert-config Debug -Osize -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
88

9-
// UNSUPPORTED: OS=wasi
9+
// UNSUPPORTED: CPU=wasm32
1010
// REQUIRES: swift_in_compiler
1111
// REQUIRES: optimized_stdlib
1212
// REQUIRES: CODEGENERATOR=ARM

test/embedded/static-object-non-darwin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -target armv7em-none-none-eabi -parse-as-library -module-name main -O -emit-ir %s -enable-experimental-feature Embedded -Xllvm -link-embedded-runtime=0 | %FileCheck %s
22
// RUN: %target-swift-frontend -target armv7em-none-none-eabi -parse-as-library -module-name main -Osize -emit-ir %s -enable-experimental-feature Embedded -Xllvm -link-embedded-runtime=0 | %FileCheck %s
33

4-
// UNSUPPORTED: OS=wasi
4+
// UNSUPPORTED: CPU=wasm32
55
// REQUIRES: swift_in_compiler
66
// REQUIRES: optimized_stdlib
77
// REQUIRES: CODEGENERATOR=ARM

test/embedded/stdlib-array.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -target armv7-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
22
// RUN: %target-swift-frontend -target arm64-apple-none-macho -emit-ir %s -enable-experimental-feature Embedded | %FileCheck %s
33

4-
// UNSUPPORTED: OS=wasi
4+
// UNSUPPORTED: CPU=wasm32
55
// REQUIRES: swift_in_compiler
66
// REQUIRES: optimized_stdlib
77
// REQUIRES: CODEGENERATOR=ARM

0 commit comments

Comments
 (0)