mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This commit focuses the basics: setting up the relevant stanzas in lit.cfg and adding platform conditionals for importing Glibc. Future commits will deal with other portability fixes.
29 lines
808 B
Swift
29 lines
808 B
Swift
// RUN: %target-build-swift -parse-as-library -sanitize=fuzzer %s -o %t
|
|
// RUN: not %t -only_ascii=1 -max_len=3 | %FileCheck %s
|
|
// REQUIRES: CPU=x86_64
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: fuzzer_runtime
|
|
// XFAIL: OS=ios
|
|
// XFAIL: OS=tvos
|
|
// XFAIL: OS=watchos
|
|
// CHECK: Crash!
|
|
|
|
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
|
|
import Darwin
|
|
#elseif os(Linux) || os(FreeBSD) || os(OpenBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
|
|
import Glibc
|
|
#elseif os(Windows)
|
|
import MSVCRT
|
|
#else
|
|
#error("Unsupported platform")
|
|
#endif
|
|
|
|
@_cdecl("LLVMFuzzerTestOneInput") public func fuzzOneInput(Data: UnsafePointer<CChar>, Size: CLong) -> CInt {
|
|
if (Size >= 3 && Data[0] == 65 && Data[1] == 66 && Data[2] == 67) {
|
|
fputs("Crash!", stdout);
|
|
fflush(stdout);
|
|
exit(1);
|
|
}
|
|
return 0;
|
|
}
|