Skip to content

Commit

Permalink
Store test content in a custom metadata section.
Browse files Browse the repository at this point in the history
See also: swiftlang/swift#76698

Resolves #735.
  • Loading branch information
grynspan committed Oct 3, 2024
1 parent b439448 commit d82e214
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Documentation/ABI/TestContent.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ the testing library are stored in dedicated platform-specific sections:

| Platform | Binary Format | Section Name |
|-|:-:|-|
| macOS | Mach-O | `__DATA_CONST,__swift5_tests` |
| iOS | Mach-O | `__DATA_CONST,__swift5_tests` |
| watchOS | Mach-O | `__DATA_CONST,__swift5_tests` |
| tvOS | Mach-O | `__DATA_CONST,__swift5_tests` |
| visionOS | Mach-O | `__DATA_CONST,__swift5_tests` |
| Linux | ELF | `PT_NOTE`[^1] |
| FreeBSD | ELF | `PT_NOTE`[^1] |
| Android | ELF | `PT_NOTE`[^1] |
| macOS, iOS, watchOS, tvOS, visionOS | Mach-O | `__DATA_CONST,__swift5_tests` |
| Linux, FreeBSD, Android | ELF | `PT_NOTE`[^1] |
| WASI | Statically Linked | `swift5_tests` |
| Windows | PE/COFF | `.sw5test` |

Expand Down Expand Up @@ -66,6 +60,11 @@ struct SWTTestContent {
};
```

This structure may grow in the future as needed. Check the `n_descsz` field of
the record header to determine if there are additional fields present. Do not
assume that the size of this structure will remain fixed over time or that all
discovered test content records are the same size.

#### The accessor field

The function `accessor` is a C function whose signature in Swift can be restated
Expand All @@ -85,9 +84,9 @@ The concrete Swift type of `accessor`'s result depends on the type of record:
| Type Value | Return Type |
|-:|-|
| < `0` | Undefined (**do not use**) |
| `0` ... `99` | `nil` |
| `0` ... `99` | Reserved (**do not use**) |
| `100` | `@Sendable () async -> Test`[^2] |
| `101` | `ExitTest` (owned by caller) |
| `101` | `ExitTest` (consumed by caller) |

[^2]: This signature is not the signature of `accessor`, but of the Swift
function reference it returns. This level of indirection is necessary
Expand Down

0 comments on commit d82e214

Please sign in to comment.