compiletest/common.rs
1use std::collections::{BTreeSet, HashMap, HashSet};
2use std::iter;
3use std::process::Command;
4use std::sync::OnceLock;
5
6use build_helper::git::GitConfig;
7use camino::{Utf8Path, Utf8PathBuf};
8use semver::Version;
9use serde::de::{Deserialize, Deserializer, Error as _};
10
11use crate::executor::{ColorConfig, OutputFormat};
12use crate::fatal;
13use crate::util::{Utf8PathBufExt, add_dylib_path, string_enum};
14
15string_enum! {
16 #[derive(Clone, Copy, PartialEq, Debug)]
17 pub enum TestMode {
18 Pretty => "pretty",
19 DebugInfo => "debuginfo",
20 Codegen => "codegen",
21 Rustdoc => "rustdoc",
22 RustdocJson => "rustdoc-json",
23 CodegenUnits => "codegen-units",
24 Incremental => "incremental",
25 RunMake => "run-make",
26 Ui => "ui",
27 RustdocJs => "rustdoc-js",
28 MirOpt => "mir-opt",
29 Assembly => "assembly",
30 CoverageMap => "coverage-map",
31 CoverageRun => "coverage-run",
32 Crashes => "crashes",
33 }
34}
35
36impl TestMode {
37 pub fn aux_dir_disambiguator(self) -> &'static str {
38 // Pretty-printing tests could run concurrently, and if they do,
39 // they need to keep their output segregated.
40 match self {
41 TestMode::Pretty => ".pretty",
42 _ => "",
43 }
44 }
45
46 pub fn output_dir_disambiguator(self) -> &'static str {
47 // Coverage tests use the same test files for multiple test modes,
48 // so each mode should have a separate output directory.
49 match self {
50 TestMode::CoverageMap | TestMode::CoverageRun => self.to_str(),
51 _ => "",
52 }
53 }
54}
55
56// Note that coverage tests use the same test files for multiple test modes.
57string_enum! {
58 #[derive(Clone, Copy, PartialEq, Debug)]
59 pub enum TestSuite {
60 Assembly => "assembly",
61 Codegen => "codegen",
62 CodegenUnits => "codegen-units",
63 Coverage => "coverage",
64 CoverageRunRustdoc => "coverage-run-rustdoc",
65 Crashes => "crashes",
66 Debuginfo => "debuginfo",
67 Incremental => "incremental",
68 MirOpt => "mir-opt",
69 Pretty => "pretty",
70 RunMake => "run-make",
71 Rustdoc => "rustdoc",
72 RustdocGui => "rustdoc-gui",
73 RustdocJs => "rustdoc-js",
74 RustdocJsStd=> "rustdoc-js-std",
75 RustdocJson => "rustdoc-json",
76 RustdocUi => "rustdoc-ui",
77 Ui => "ui",
78 UiFullDeps => "ui-fulldeps",
79 }
80}
81
82string_enum! {
83 #[derive(Clone, Copy, PartialEq, Debug, Hash)]
84 pub enum PassMode {
85 Check => "check",
86 Build => "build",
87 Run => "run",
88 }
89}
90
91#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
92pub enum FailMode {
93 Check,
94 Build,
95 Run,
96}
97
98string_enum! {
99 #[derive(Clone, Debug, PartialEq)]
100 pub enum CompareMode {
101 Polonius => "polonius",
102 NextSolver => "next-solver",
103 NextSolverCoherence => "next-solver-coherence",
104 SplitDwarf => "split-dwarf",
105 SplitDwarfSingle => "split-dwarf-single",
106 }
107}
108
109string_enum! {
110 #[derive(Clone, Copy, Debug, PartialEq)]
111 pub enum Debugger {
112 Cdb => "cdb",
113 Gdb => "gdb",
114 Lldb => "lldb",
115 }
116}
117
118#[derive(Clone, Copy, Debug, PartialEq, Default, serde::Deserialize)]
119#[serde(rename_all = "kebab-case")]
120pub enum PanicStrategy {
121 #[default]
122 Unwind,
123 Abort,
124}
125
126impl PanicStrategy {
127 pub(crate) fn for_miropt_test_tools(&self) -> miropt_test_tools::PanicStrategy {
128 match self {
129 PanicStrategy::Unwind => miropt_test_tools::PanicStrategy::Unwind,
130 PanicStrategy::Abort => miropt_test_tools::PanicStrategy::Abort,
131 }
132 }
133}
134
135#[derive(Clone, Debug, PartialEq, serde::Deserialize)]
136#[serde(rename_all = "kebab-case")]
137pub enum Sanitizer {
138 Address,
139 Cfi,
140 Dataflow,
141 Kcfi,
142 KernelAddress,
143 Leak,
144 Memory,
145 Memtag,
146 Safestack,
147 ShadowCallStack,
148 Thread,
149 Hwaddress,
150}
151
152/// Configuration for `compiletest` *per invocation*.
153///
154/// In terms of `bootstrap`, this means that `./x test tests/ui tests/run-make` actually correspond
155/// to *two* separate invocations of `compiletest`.
156///
157/// FIXME: this `Config` struct should be broken up into smaller logically contained sub-config
158/// structs, it's too much of a "soup" of everything at the moment.
159///
160/// # Configuration sources
161///
162/// Configuration values for `compiletest` comes from several sources:
163///
164/// - CLI args passed from `bootstrap` while running the `compiletest` binary.
165/// - Env vars.
166/// - Discovery (e.g. trying to identify a suitable debugger based on filesystem discovery).
167/// - Cached output of running the `rustc` under test (e.g. output of `rustc` print requests).
168///
169/// FIXME: make sure we *clearly* account for sources of *all* config options.
170///
171/// FIXME: audit these options to make sure we are not hashing less than necessary for build stamp
172/// (for changed test detection).
173#[derive(Debug, Clone)]
174pub struct Config {
175 /// Some [`TestMode`]s support [snapshot testing], where a *reference snapshot* of outputs (of
176 /// `stdout`, `stderr`, or other form of artifacts) can be compared to the *actual output*.
177 ///
178 /// This option can be set to `true` to update the *reference snapshots* in-place, otherwise
179 /// `compiletest` will only try to compare.
180 ///
181 /// [snapshot testing]: https://jestjs.io/docs/snapshot-testing
182 pub bless: bool,
183
184 /// Attempt to stop as soon as possible after any test fails. We may still run a few more tests
185 /// before stopping when multiple test threads are used.
186 pub fail_fast: bool,
187
188 /// Path to libraries needed to run the *staged* `rustc`-under-test on the **host** platform.
189 ///
190 /// FIXME: maybe rename this to reflect (1) which target platform (host, not target), and (2)
191 /// which `rustc` (the `rustc`-under-test, not the stage 0 `rustc` unless forced).
192 pub compile_lib_path: Utf8PathBuf,
193
194 /// Path to libraries needed to run the compiled executable for the **target** platform. This
195 /// corresponds to the **target** sysroot libraries, including the **target** standard library.
196 ///
197 /// FIXME: maybe rename this to reflect (1) which target platform (target, not host), and (2)
198 /// what "run libraries" are against.
199 ///
200 /// FIXME: this is very under-documented in conjunction with the `remote-test-client` scheme and
201 /// `RUNNER` scheme to actually run the target executable under the target platform environment,
202 /// cf. [`Self::remote_test_client`] and [`Self::runner`].
203 pub run_lib_path: Utf8PathBuf,
204
205 /// Path to the *staged* `rustc`-under-test. Unless forced, this `rustc` is *staged*, and must
206 /// not be confused with [`Self::stage0_rustc_path`].
207 ///
208 /// FIXME: maybe rename this to reflect that this is the `rustc`-under-test.
209 pub rustc_path: Utf8PathBuf,
210
211 /// Path to a *staged* **host** platform cargo executable (unless stage 0 is forced). This
212 /// staged `cargo` is only used within `run-make` test recipes during recipe run time (and is
213 /// *not* used to compile the test recipes), and so must be staged as there may be differences
214 /// between e.g. beta `cargo` vs in-tree `cargo`.
215 ///
216 /// FIXME: maybe rename this to reflect that this is a *staged* host cargo.
217 ///
218 /// FIXME(#134109): split `run-make` into two test suites, a test suite *with* staged cargo, and
219 /// another test suite *without*.
220 pub cargo_path: Option<Utf8PathBuf>,
221
222 /// Path to the stage 0 `rustc` used to build `run-make` recipes. This must not be confused with
223 /// [`Self::rustc_path`].
224 pub stage0_rustc_path: Option<Utf8PathBuf>,
225
226 /// Path to the `rustdoc`-under-test. Like [`Self::rustc_path`], this `rustdoc` is *staged*.
227 pub rustdoc_path: Option<Utf8PathBuf>,
228
229 /// Path to the `src/tools/coverage-dump/` bootstrap tool executable.
230 pub coverage_dump_path: Option<Utf8PathBuf>,
231
232 /// Path to the Python 3 executable to use for LLDB and htmldocck.
233 ///
234 /// FIXME: the `lldb` setup currently requires I believe Python 3.10 **exactly**, it can't even
235 /// be Python 3.11 or 3.9...
236 pub python: String,
237
238 /// Path to the `src/tools/jsondocck/` bootstrap tool executable.
239 pub jsondocck_path: Option<String>,
240
241 /// Path to the `src/tools/jsondoclint/` bootstrap tool executable.
242 pub jsondoclint_path: Option<String>,
243
244 /// Path to a host LLVM `FileCheck` executable.
245 pub llvm_filecheck: Option<Utf8PathBuf>,
246
247 /// Path to a host LLVM bintools directory.
248 pub llvm_bin_dir: Option<Utf8PathBuf>,
249
250 /// The path to the **target** `clang` executable to run `clang`-based tests with. If `None`,
251 /// then these tests will be ignored.
252 pub run_clang_based_tests_with: Option<String>,
253
254 /// Path to the directory containing the sources. This corresponds to the root folder of a
255 /// `rust-lang/rust` checkout.
256 ///
257 /// FIXME: this name is confusing, because this is actually `$checkout_root`, **not** the
258 /// `$checkout_root/src/` folder.
259 pub src_root: Utf8PathBuf,
260
261 /// Path to the directory containing the test suites sources. This corresponds to the
262 /// `$src_root/tests/` folder.
263 ///
264 /// Must be an immediate subdirectory of [`Self::src_root`].
265 ///
266 /// FIXME: this name is also confusing, maybe just call it `tests_root`.
267 pub src_test_suite_root: Utf8PathBuf,
268
269 /// Path to the build directory (e.g. `build/`).
270 pub build_root: Utf8PathBuf,
271
272 /// Path to the test suite specific build directory (e.g. `build/host/test/ui/`).
273 ///
274 /// Must be a subdirectory of [`Self::build_root`].
275 pub build_test_suite_root: Utf8PathBuf,
276
277 /// Path to the directory containing the sysroot of the `rustc`-under-test.
278 ///
279 /// When stage 0 is forced, this will correspond to the sysroot *of* that specified stage 0
280 /// `rustc`.
281 ///
282 /// FIXME: this name is confusing, because it doesn't specify *which* compiler this sysroot
283 /// corresponds to. It's actually the `rustc`-under-test, and not the bootstrap `rustc`, unless
284 /// stage 0 is forced and no custom stage 0 `rustc` was otherwise specified (so that it
285 /// *happens* to run against the bootstrap `rustc`, but this non-custom bootstrap `rustc` case
286 /// is not really supported).
287 pub sysroot_base: Utf8PathBuf,
288
289 /// The number of the stage under test.
290 pub stage: u32,
291
292 /// The id of the stage under test (stage1-xxx, etc).
293 ///
294 /// FIXME: reconsider this string; this is hashed for test build stamp.
295 pub stage_id: String,
296
297 /// The [`TestMode`]. E.g. [`TestMode::Ui`]. Each test mode can correspond to one or more test
298 /// suites.
299 ///
300 /// FIXME: stop using stringly-typed test suites!
301 pub mode: TestMode,
302
303 /// The test suite.
304 ///
305 /// Example: `tests/ui/` is [`TestSuite::Ui`] test *suite*, which happens to also be of the
306 /// [`TestMode::Ui`] test *mode*.
307 ///
308 /// Note that the same test suite (e.g. `tests/coverage/`) may correspond to multiple test
309 /// modes, e.g. `tests/coverage/` can be run under both [`TestMode::CoverageRun`] and
310 /// [`TestMode::CoverageMap`].
311 pub suite: TestSuite,
312
313 /// When specified, **only** the specified [`Debugger`] will be used to run against the
314 /// `tests/debuginfo` test suite. When unspecified, `compiletest` will attempt to find all three
315 /// of {`lldb`, `cdb`, `gdb`} implicitly, and then try to run the `debuginfo` test suite against
316 /// all three debuggers.
317 ///
318 /// FIXME: this implicit behavior is really nasty, in that it makes it hard for the user to
319 /// control *which* debugger(s) are available and used to run the debuginfo test suite. We
320 /// should have `bootstrap` allow the user to *explicitly* configure the debuggers, and *not*
321 /// try to implicitly discover some random debugger from the user environment. This makes the
322 /// debuginfo test suite particularly hard to work with.
323 pub debugger: Option<Debugger>,
324
325 /// Run ignored tests *unconditionally*, overriding their ignore reason.
326 ///
327 /// FIXME: this is wired up through the test execution logic, but **not** accessible from
328 /// `bootstrap` directly; `compiletest` exposes this as `--ignored`. I.e. you'd have to use `./x
329 /// test $test_suite -- --ignored=true`.
330 pub run_ignored: bool,
331
332 /// Whether *staged* `rustc`-under-test was built with debug assertions.
333 ///
334 /// FIXME: make it clearer that this refers to the staged `rustc`-under-test, not stage 0
335 /// `rustc`.
336 pub with_rustc_debug_assertions: bool,
337
338 /// Whether *staged* `std` was built with debug assertions.
339 ///
340 /// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
341 pub with_std_debug_assertions: bool,
342
343 /// Only run tests that match these filters (using `libtest` "test name contains" filter logic).
344 ///
345 /// FIXME(#139660): the current hand-rolled test executor intentionally mimics the `libtest`
346 /// "test name contains" filter matching logic to preserve previous `libtest` executor behavior,
347 /// but this is often not intuitive. We should consider changing that behavior with an MCP to do
348 /// test path *prefix* matching which better corresponds to how `compiletest` `tests/` are
349 /// organized, and how users would intuitively expect the filtering logic to work like.
350 pub filters: Vec<String>,
351
352 /// Skip tests matching these substrings. The matching logic exactly corresponds to
353 /// [`Self::filters`] but inverted.
354 ///
355 /// FIXME(#139660): ditto on test matching behavior.
356 pub skip: Vec<String>,
357
358 /// Exactly match the filter, rather than a substring.
359 ///
360 /// FIXME(#139660): ditto on test matching behavior.
361 pub filter_exact: bool,
362
363 /// Force the pass mode of a check/build/run test to instead use this mode instead.
364 ///
365 /// FIXME: make it even more obvious (especially in PR CI where `--pass=check` is used) when a
366 /// pass mode is forced when the test fails, because it can be very non-obvious when e.g. an
367 /// error is emitted only when `//@ build-pass` but not `//@ check-pass`.
368 pub force_pass_mode: Option<PassMode>,
369
370 /// Explicitly enable or disable running of the target test binary.
371 ///
372 /// FIXME: this scheme is a bit confusing, and at times questionable. Re-evaluate this run
373 /// scheme.
374 ///
375 /// FIXME: Currently `--run` is a tri-state, it can be `--run={auto,always,never}`, and when
376 /// `--run=auto` is specified, it's run if the platform doesn't end with `-fuchsia`. See
377 /// [`Config::run_enabled`].
378 pub run: Option<bool>,
379
380 /// A command line to prefix target program execution with, for running under valgrind for
381 /// example, i.e. `$runner target.exe [args..]`. Similar to `CARGO_*_RUNNER` configuration.
382 ///
383 /// Note: this is not to be confused with [`Self::remote_test_client`], which is a different
384 /// scheme.
385 ///
386 /// FIXME: the runner scheme is very under-documented.
387 pub runner: Option<String>,
388
389 /// Compiler flags to pass to the *staged* `rustc`-under-test when building for the **host**
390 /// platform.
391 pub host_rustcflags: Vec<String>,
392
393 /// Compiler flags to pass to the *staged* `rustc`-under-test when building for the **target**
394 /// platform.
395 pub target_rustcflags: Vec<String>,
396
397 /// Whether the *staged* `rustc`-under-test and the associated *staged* `std` has been built
398 /// with randomized struct layouts.
399 pub rust_randomized_layout: bool,
400
401 /// Whether tests should be optimized by default (`-O`). Individual test suites and test files
402 /// may override this setting.
403 ///
404 /// FIXME: this flag / config option is somewhat misleading. For instance, in ui tests, it's
405 /// *only* applied to the [`PassMode::Run`] test crate and not its auxiliaries.
406 pub optimize_tests: bool,
407
408 /// Target platform tuple.
409 pub target: String,
410
411 /// Host platform tuple.
412 pub host: String,
413
414 /// Path to / name of the Microsoft Console Debugger (CDB) executable.
415 ///
416 /// FIXME: this is an *opt-in* "override" option. When this isn't provided, we try to conjure a
417 /// cdb by looking at the user's program files on Windows... See `debuggers::find_cdb`.
418 pub cdb: Option<Utf8PathBuf>,
419
420 /// Version of CDB.
421 ///
422 /// FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config!
423 ///
424 /// FIXME: audit cdb version gating.
425 pub cdb_version: Option<[u16; 4]>,
426
427 /// Path to / name of the GDB executable.
428 ///
429 /// FIXME: the fallback path when `gdb` isn't provided tries to find *a* `gdb` or `gdb.exe` from
430 /// `PATH`, which is... arguably questionable.
431 ///
432 /// FIXME: we are propagating a python from `PYTHONPATH`, not from an explicit config for gdb
433 /// debugger script.
434 pub gdb: Option<String>,
435
436 /// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
437 ///
438 /// FIXME: this gdb version gating scheme is possibly questionable -- gdb does not use semver,
439 /// only its major version is likely materially meaningful, cf.
440 /// <https://sourceware.org/gdb/wiki/Internals%20Versions>. Even the major version I'm not sure
441 /// is super meaningful. Maybe min gdb `major.minor` version gating is sufficient for the
442 /// purposes of debuginfo tests?
443 ///
444 /// FIXME: `gdb_version` is *derived* from gdb, but it's *not* technically a config!
445 pub gdb_version: Option<u32>,
446
447 /// Version of LLDB.
448 ///
449 /// FIXME: `lldb_version` is *derived* from lldb, but it's *not* technically a config!
450 pub lldb_version: Option<u32>,
451
452 /// Version of LLVM.
453 ///
454 /// FIXME: Audit the fallback derivation of
455 /// [`crate::directives::extract_llvm_version_from_binary`], that seems very questionable?
456 pub llvm_version: Option<Version>,
457
458 /// Is LLVM a system LLVM.
459 pub system_llvm: bool,
460
461 /// Path to the android tools.
462 ///
463 /// Note: this is only used for android gdb debugger script in the debuginfo test suite.
464 ///
465 /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
466 /// `arm-linux-androideabi` target.
467 pub android_cross_path: Utf8PathBuf,
468
469 /// Extra parameter to run adb on `arm-linux-androideabi`.
470 ///
471 /// FIXME: is this *only* `arm-linux-androideabi`, or is it also for other Tier 2/3 android
472 /// targets?
473 ///
474 /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
475 /// `arm-linux-androideabi` target.
476 pub adb_path: String,
477
478 /// Extra parameter to run test suite on `arm-linux-androideabi`.
479 ///
480 /// FIXME: is this *only* `arm-linux-androideabi`, or is it also for other Tier 2/3 android
481 /// targets?
482 ///
483 /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
484 /// `arm-linux-androideabi` target.
485 pub adb_test_dir: String,
486
487 /// Status whether android device available or not. When unavailable, this will cause tests to
488 /// panic when the test binary is attempted to be run.
489 ///
490 /// FIXME: take a look at this; this also influences adb in gdb code paths in a strange way.
491 pub adb_device_status: bool,
492
493 /// Path containing LLDB's Python module.
494 ///
495 /// FIXME: `PYTHONPATH` takes precedence over this flag...? See `runtest::run_lldb`.
496 pub lldb_python_dir: Option<String>,
497
498 /// Verbose dump a lot of info.
499 ///
500 /// FIXME: this is *way* too coarse; the user can't select *which* info to verbosely dump.
501 pub verbose: bool,
502
503 /// (Useless) Adjust libtest output format.
504 ///
505 /// FIXME: the hand-rolled executor does not support non-JSON output, because `compiletest` need
506 /// to package test outcome as `libtest`-esque JSON that `bootstrap` can intercept *anyway*.
507 /// However, now that we don't use the `libtest` executor, this is useless.
508 pub format: OutputFormat,
509
510 /// Whether to use colors in test output.
511 ///
512 /// Note: the exact control mechanism is delegated to [`colored`].
513 pub color: ColorConfig,
514
515 /// Where to find the remote test client process, if we're using it.
516 ///
517 /// Note: this is *only* used for target platform executables created by `run-make` test
518 /// recipes.
519 ///
520 /// Note: this is not to be confused with [`Self::runner`], which is a different scheme.
521 ///
522 /// FIXME: the `remote_test_client` scheme is very under-documented.
523 pub remote_test_client: Option<Utf8PathBuf>,
524
525 /// [`CompareMode`] describing what file the actual ui output will be compared to.
526 ///
527 /// FIXME: currently, [`CompareMode`] is a mishmash of lot of things (different borrow-checker
528 /// model, different trait solver, different debugger, etc.).
529 pub compare_mode: Option<CompareMode>,
530
531 /// If true, this will generate a coverage file with UI test files that run `MachineApplicable`
532 /// diagnostics but are missing `run-rustfix` annotations. The generated coverage file is
533 /// created in `$test_suite_build_root/rustfix_missing_coverage.txt`
534 pub rustfix_coverage: bool,
535
536 /// Whether to run `tidy` (html-tidy) when a rustdoc test fails.
537 pub has_html_tidy: bool,
538
539 /// Whether to run `enzyme` autodiff tests.
540 pub has_enzyme: bool,
541
542 /// The current Rust channel info.
543 ///
544 /// FIXME: treat this more carefully; "stable", "beta" and "nightly" are definitely valid, but
545 /// channel might also be "dev" or such, which should be treated as "nightly".
546 pub channel: String,
547
548 /// Whether adding git commit information such as the commit hash has been enabled for building.
549 ///
550 /// FIXME: `compiletest` cannot trust `bootstrap` for this information, because `bootstrap` can
551 /// have bugs and had bugs on that logic. We need to figure out how to obtain this e.g. directly
552 /// from CI or via git locally.
553 pub git_hash: bool,
554
555 /// The default Rust edition.
556 ///
557 /// FIXME: perform stronger validation for this. There are editions that *definitely* exists,
558 /// but there might also be "future" edition.
559 pub edition: Option<String>,
560
561 // Configuration for various run-make tests frobbing things like C compilers or querying about
562 // various LLVM component information.
563 //
564 // FIXME: this really should be better packaged together.
565 // FIXME: these need better docs, e.g. for *host*, or for *target*?
566 pub cc: String,
567 pub cxx: String,
568 pub cflags: String,
569 pub cxxflags: String,
570 pub ar: String,
571 pub target_linker: Option<String>,
572 pub host_linker: Option<String>,
573 pub llvm_components: String,
574
575 /// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests.
576 pub nodejs: Option<String>,
577 /// Path to a npm executable. Used for rustdoc GUI tests.
578 pub npm: Option<String>,
579
580 /// Whether to rerun tests even if the inputs are unchanged.
581 pub force_rerun: bool,
582
583 /// Only rerun the tests that result has been modified according to `git status`.
584 ///
585 /// FIXME: this is undocumented.
586 ///
587 /// FIXME: how does this interact with [`Self::force_rerun`]?
588 pub only_modified: bool,
589
590 // FIXME: these are really not "config"s, but rather are information derived from
591 // `rustc`-under-test. This poses an interesting conundrum: if we're testing the
592 // `rustc`-under-test, can we trust its print request outputs and target cfgs? In theory, this
593 // itself can break or be unreliable -- ideally, we'd be sharing these kind of information not
594 // through `rustc`-under-test's execution output. In practice, however, print requests are very
595 // unlikely to completely break (we also have snapshot ui tests for them). Furthermore, even if
596 // we share them via some kind of static config, that static config can still be wrong! Who
597 // tests the tester? Therefore, we make a pragmatic compromise here, and use information derived
598 // from print requests produced by the `rustc`-under-test.
599 //
600 // FIXME: move them out from `Config`, because they are *not* configs.
601 pub target_cfgs: OnceLock<TargetCfgs>,
602 pub builtin_cfg_names: OnceLock<HashSet<String>>,
603 pub supported_crate_types: OnceLock<HashSet<String>>,
604
605 /// FIXME: this is why we still need to depend on *staged* `std`, it's because we currently rely
606 /// on `#![feature(internal_output_capture)]` for [`std::io::set_output_capture`] to implement
607 /// `libtest`-esque `--no-capture`.
608 ///
609 /// FIXME: rename this to the more canonical `no_capture`, or better, invert this to `capture`
610 /// to avoid `!nocapture` double-negatives.
611 pub nocapture: bool,
612
613 /// Needed both to construct [`build_helper::git::GitConfig`].
614 pub nightly_branch: String,
615 pub git_merge_commit_email: String,
616
617 /// True if the profiler runtime is enabled for this target. Used by the
618 /// `needs-profiler-runtime` directive in test files.
619 pub profiler_runtime: bool,
620
621 /// Command for visual diff display, e.g. `diff-tool --color=always`.
622 pub diff_command: Option<String>,
623
624 /// Path to minicore aux library (`tests/auxiliary/minicore.rs`), used for `no_core` tests that
625 /// need `core` stubs in cross-compilation scenarios that do not otherwise want/need to
626 /// `-Zbuild-std`. Used in e.g. ABI tests.
627 pub minicore_path: Utf8PathBuf,
628}
629
630impl Config {
631 /// Incomplete config intended for `src/tools/rustdoc-gui-test` **only** as
632 /// `src/tools/rustdoc-gui-test` wants to reuse `compiletest`'s directive -> test property
633 /// handling for `//@ {compile,run}-flags`, do not use for any other purpose.
634 ///
635 /// FIXME(#143827): this setup feels very hacky. It so happens that `tests/rustdoc-gui/`
636 /// **only** uses `//@ {compile,run}-flags` for now and not any directives that actually rely on
637 /// info that is assumed available in a fully populated [`Config`].
638 pub fn incomplete_for_rustdoc_gui_test() -> Config {
639 // FIXME(#143827): spelling this out intentionally, because this is questionable.
640 //
641 // For instance, `//@ ignore-stage1` will not work at all.
642 Config {
643 mode: TestMode::Rustdoc,
644 // E.g. this has no sensible default tbh.
645 suite: TestSuite::Ui,
646
647 // Dummy values.
648 edition: Default::default(),
649 bless: Default::default(),
650 fail_fast: Default::default(),
651 compile_lib_path: Utf8PathBuf::default(),
652 run_lib_path: Utf8PathBuf::default(),
653 rustc_path: Utf8PathBuf::default(),
654 cargo_path: Default::default(),
655 stage0_rustc_path: Default::default(),
656 rustdoc_path: Default::default(),
657 coverage_dump_path: Default::default(),
658 python: Default::default(),
659 jsondocck_path: Default::default(),
660 jsondoclint_path: Default::default(),
661 llvm_filecheck: Default::default(),
662 llvm_bin_dir: Default::default(),
663 run_clang_based_tests_with: Default::default(),
664 src_root: Utf8PathBuf::default(),
665 src_test_suite_root: Utf8PathBuf::default(),
666 build_root: Utf8PathBuf::default(),
667 build_test_suite_root: Utf8PathBuf::default(),
668 sysroot_base: Utf8PathBuf::default(),
669 stage: Default::default(),
670 stage_id: String::default(),
671 debugger: Default::default(),
672 run_ignored: Default::default(),
673 with_rustc_debug_assertions: Default::default(),
674 with_std_debug_assertions: Default::default(),
675 filters: Default::default(),
676 skip: Default::default(),
677 filter_exact: Default::default(),
678 force_pass_mode: Default::default(),
679 run: Default::default(),
680 runner: Default::default(),
681 host_rustcflags: Default::default(),
682 target_rustcflags: Default::default(),
683 rust_randomized_layout: Default::default(),
684 optimize_tests: Default::default(),
685 target: Default::default(),
686 host: Default::default(),
687 cdb: Default::default(),
688 cdb_version: Default::default(),
689 gdb: Default::default(),
690 gdb_version: Default::default(),
691 lldb_version: Default::default(),
692 llvm_version: Default::default(),
693 system_llvm: Default::default(),
694 android_cross_path: Default::default(),
695 adb_path: Default::default(),
696 adb_test_dir: Default::default(),
697 adb_device_status: Default::default(),
698 lldb_python_dir: Default::default(),
699 verbose: Default::default(),
700 format: Default::default(),
701 color: Default::default(),
702 remote_test_client: Default::default(),
703 compare_mode: Default::default(),
704 rustfix_coverage: Default::default(),
705 has_html_tidy: Default::default(),
706 has_enzyme: Default::default(),
707 channel: Default::default(),
708 git_hash: Default::default(),
709 cc: Default::default(),
710 cxx: Default::default(),
711 cflags: Default::default(),
712 cxxflags: Default::default(),
713 ar: Default::default(),
714 target_linker: Default::default(),
715 host_linker: Default::default(),
716 llvm_components: Default::default(),
717 nodejs: Default::default(),
718 npm: Default::default(),
719 force_rerun: Default::default(),
720 only_modified: Default::default(),
721 target_cfgs: Default::default(),
722 builtin_cfg_names: Default::default(),
723 supported_crate_types: Default::default(),
724 nocapture: Default::default(),
725 nightly_branch: Default::default(),
726 git_merge_commit_email: Default::default(),
727 profiler_runtime: Default::default(),
728 diff_command: Default::default(),
729 minicore_path: Default::default(),
730 }
731 }
732
733 /// FIXME: this run scheme is... confusing.
734 pub fn run_enabled(&self) -> bool {
735 self.run.unwrap_or_else(|| {
736 // Auto-detect whether to run based on the platform.
737 !self.target.ends_with("-fuchsia")
738 })
739 }
740
741 pub fn target_cfgs(&self) -> &TargetCfgs {
742 self.target_cfgs.get_or_init(|| TargetCfgs::new(self))
743 }
744
745 pub fn target_cfg(&self) -> &TargetCfg {
746 &self.target_cfgs().current
747 }
748
749 pub fn matches_arch(&self, arch: &str) -> bool {
750 self.target_cfg().arch == arch ||
751 // Matching all the thumb variants as one can be convenient.
752 // (thumbv6m, thumbv7em, thumbv7m, etc.)
753 (arch == "thumb" && self.target.starts_with("thumb"))
754 }
755
756 pub fn matches_os(&self, os: &str) -> bool {
757 self.target_cfg().os == os
758 }
759
760 pub fn matches_env(&self, env: &str) -> bool {
761 self.target_cfg().env == env
762 }
763
764 pub fn matches_abi(&self, abi: &str) -> bool {
765 self.target_cfg().abi == abi
766 }
767
768 pub fn matches_family(&self, family: &str) -> bool {
769 self.target_cfg().families.iter().any(|f| f == family)
770 }
771
772 pub fn is_big_endian(&self) -> bool {
773 self.target_cfg().endian == Endian::Big
774 }
775
776 pub fn get_pointer_width(&self) -> u32 {
777 *&self.target_cfg().pointer_width
778 }
779
780 pub fn can_unwind(&self) -> bool {
781 self.target_cfg().panic == PanicStrategy::Unwind
782 }
783
784 /// Get the list of builtin, 'well known' cfg names
785 pub fn builtin_cfg_names(&self) -> &HashSet<String> {
786 self.builtin_cfg_names.get_or_init(|| builtin_cfg_names(self))
787 }
788
789 /// Get the list of crate types that the target platform supports.
790 pub fn supported_crate_types(&self) -> &HashSet<String> {
791 self.supported_crate_types.get_or_init(|| supported_crate_types(self))
792 }
793
794 pub fn has_threads(&self) -> bool {
795 // Wasm targets don't have threads unless `-threads` is in the target
796 // name, such as `wasm32-wasip1-threads`.
797 if self.target.starts_with("wasm") {
798 return self.target.contains("threads");
799 }
800 true
801 }
802
803 pub fn has_asm_support(&self) -> bool {
804 // This should match the stable list in `LoweringContext::lower_inline_asm`.
805 static ASM_SUPPORTED_ARCHS: &[&str] = &[
806 "x86",
807 "x86_64",
808 "arm",
809 "aarch64",
810 "arm64ec",
811 "riscv32",
812 "riscv64",
813 "loongarch32",
814 "loongarch64",
815 "s390x",
816 // These targets require an additional asm_experimental_arch feature.
817 // "nvptx64", "hexagon", "mips", "mips64", "spirv", "wasm32",
818 ];
819 ASM_SUPPORTED_ARCHS.contains(&self.target_cfg().arch.as_str())
820 }
821
822 pub fn git_config(&self) -> GitConfig<'_> {
823 GitConfig {
824 nightly_branch: &self.nightly_branch,
825 git_merge_commit_email: &self.git_merge_commit_email,
826 }
827 }
828
829 pub fn has_subprocess_support(&self) -> bool {
830 // FIXME(#135928): compiletest is always a **host** tool. Building and running an
831 // capability detection executable against the **target** is not trivial. The short term
832 // solution here is to hard-code some targets to allow/deny, unfortunately.
833
834 let unsupported_target = self.target_cfg().env == "sgx"
835 || matches!(self.target_cfg().arch.as_str(), "wasm32" | "wasm64")
836 || self.target_cfg().os == "emscripten";
837 !unsupported_target
838 }
839}
840
841/// Known widths of `target_has_atomic`.
842pub const KNOWN_TARGET_HAS_ATOMIC_WIDTHS: &[&str] = &["8", "16", "32", "64", "128", "ptr"];
843
844#[derive(Debug, Clone)]
845pub struct TargetCfgs {
846 pub current: TargetCfg,
847 pub all_targets: HashSet<String>,
848 pub all_archs: HashSet<String>,
849 pub all_oses: HashSet<String>,
850 pub all_oses_and_envs: HashSet<String>,
851 pub all_envs: HashSet<String>,
852 pub all_abis: HashSet<String>,
853 pub all_families: HashSet<String>,
854 pub all_pointer_widths: HashSet<String>,
855 pub all_rustc_abis: HashSet<String>,
856}
857
858impl TargetCfgs {
859 fn new(config: &Config) -> TargetCfgs {
860 let mut targets: HashMap<String, TargetCfg> = serde_json::from_str(&rustc_output(
861 config,
862 &["--print=all-target-specs-json", "-Zunstable-options"],
863 Default::default(),
864 ))
865 .unwrap();
866
867 let mut all_targets = HashSet::new();
868 let mut all_archs = HashSet::new();
869 let mut all_oses = HashSet::new();
870 let mut all_oses_and_envs = HashSet::new();
871 let mut all_envs = HashSet::new();
872 let mut all_abis = HashSet::new();
873 let mut all_families = HashSet::new();
874 let mut all_pointer_widths = HashSet::new();
875 // NOTE: for distinction between `abi` and `rustc_abi`, see comment on
876 // `TargetCfg::rustc_abi`.
877 let mut all_rustc_abis = HashSet::new();
878
879 // If current target is not included in the `--print=all-target-specs-json` output,
880 // we check whether it is a custom target from the user or a synthetic target from bootstrap.
881 if !targets.contains_key(&config.target) {
882 let mut envs: HashMap<String, String> = HashMap::new();
883
884 if let Ok(t) = std::env::var("RUST_TARGET_PATH") {
885 envs.insert("RUST_TARGET_PATH".into(), t);
886 }
887
888 // This returns false only when the target is neither a synthetic target
889 // nor a custom target from the user, indicating it is most likely invalid.
890 if config.target.ends_with(".json") || !envs.is_empty() {
891 targets.insert(
892 config.target.clone(),
893 serde_json::from_str(&rustc_output(
894 config,
895 &[
896 "--print=target-spec-json",
897 "-Zunstable-options",
898 "--target",
899 &config.target,
900 ],
901 envs,
902 ))
903 .unwrap(),
904 );
905 }
906 }
907
908 for (target, cfg) in targets.iter() {
909 all_archs.insert(cfg.arch.clone());
910 all_oses.insert(cfg.os.clone());
911 all_oses_and_envs.insert(cfg.os_and_env());
912 all_envs.insert(cfg.env.clone());
913 all_abis.insert(cfg.abi.clone());
914 for family in &cfg.families {
915 all_families.insert(family.clone());
916 }
917 all_pointer_widths.insert(format!("{}bit", cfg.pointer_width));
918 if let Some(rustc_abi) = &cfg.rustc_abi {
919 all_rustc_abis.insert(rustc_abi.clone());
920 }
921 all_targets.insert(target.clone());
922 }
923
924 Self {
925 current: Self::get_current_target_config(config, &targets),
926 all_targets,
927 all_archs,
928 all_oses,
929 all_oses_and_envs,
930 all_envs,
931 all_abis,
932 all_families,
933 all_pointer_widths,
934 all_rustc_abis,
935 }
936 }
937
938 fn get_current_target_config(
939 config: &Config,
940 targets: &HashMap<String, TargetCfg>,
941 ) -> TargetCfg {
942 let mut cfg = targets[&config.target].clone();
943
944 // To get the target information for the current target, we take the target spec obtained
945 // from `--print=all-target-specs-json`, and then we enrich it with the information
946 // gathered from `--print=cfg --target=$target`.
947 //
948 // This is done because some parts of the target spec can be overridden with `-C` flags,
949 // which are respected for `--print=cfg` but not for `--print=all-target-specs-json`. The
950 // code below extracts them from `--print=cfg`: make sure to only override fields that can
951 // actually be changed with `-C` flags.
952 for config in
953 rustc_output(config, &["--print=cfg", "--target", &config.target], Default::default())
954 .trim()
955 .lines()
956 {
957 let (name, value) = config
958 .split_once("=\"")
959 .map(|(name, value)| {
960 (
961 name,
962 Some(
963 value
964 .strip_suffix('\"')
965 .expect("key-value pair should be properly quoted"),
966 ),
967 )
968 })
969 .unwrap_or_else(|| (config, None));
970
971 match (name, value) {
972 // Can be overridden with `-C panic=$strategy`.
973 ("panic", Some("abort")) => cfg.panic = PanicStrategy::Abort,
974 ("panic", Some("unwind")) => cfg.panic = PanicStrategy::Unwind,
975 ("panic", other) => panic!("unexpected value for panic cfg: {other:?}"),
976
977 ("target_has_atomic", Some(width))
978 if KNOWN_TARGET_HAS_ATOMIC_WIDTHS.contains(&width) =>
979 {
980 cfg.target_has_atomic.insert(width.to_string());
981 }
982 ("target_has_atomic", Some(other)) => {
983 panic!("unexpected value for `target_has_atomic` cfg: {other:?}")
984 }
985 // Nightly-only std-internal impl detail.
986 ("target_has_atomic", None) => {}
987 _ => {}
988 }
989 }
990
991 cfg
992 }
993}
994
995#[derive(Clone, Debug, serde::Deserialize)]
996#[serde(rename_all = "kebab-case")]
997pub struct TargetCfg {
998 pub(crate) arch: String,
999 #[serde(default = "default_os")]
1000 pub(crate) os: String,
1001 #[serde(default)]
1002 pub(crate) env: String,
1003 #[serde(default)]
1004 pub(crate) abi: String,
1005 #[serde(rename = "target-family", default)]
1006 pub(crate) families: Vec<String>,
1007 #[serde(rename = "target-pointer-width", deserialize_with = "serde_parse_u32")]
1008 pub(crate) pointer_width: u32,
1009 #[serde(rename = "target-endian", default)]
1010 endian: Endian,
1011 #[serde(rename = "panic-strategy", default)]
1012 pub(crate) panic: PanicStrategy,
1013 #[serde(default)]
1014 pub(crate) dynamic_linking: bool,
1015 #[serde(rename = "supported-sanitizers", default)]
1016 pub(crate) sanitizers: Vec<Sanitizer>,
1017 #[serde(rename = "supports-xray", default)]
1018 pub(crate) xray: bool,
1019 #[serde(default = "default_reloc_model")]
1020 pub(crate) relocation_model: String,
1021 // NOTE: `rustc_abi` should not be confused with `abi`. `rustc_abi` was introduced in #137037 to
1022 // make SSE2 *required* by the ABI (kind of a hack to make a target feature *required* via the
1023 // target spec).
1024 pub(crate) rustc_abi: Option<String>,
1025
1026 // Not present in target cfg json output, additional derived information.
1027 #[serde(skip)]
1028 /// Supported target atomic widths: e.g. `8` to `128` or `ptr`. This is derived from the builtin
1029 /// `target_has_atomic` `cfg`s e.g. `target_has_atomic="8"`.
1030 pub(crate) target_has_atomic: BTreeSet<String>,
1031}
1032
1033impl TargetCfg {
1034 pub(crate) fn os_and_env(&self) -> String {
1035 format!("{}-{}", self.os, self.env)
1036 }
1037}
1038
1039fn default_os() -> String {
1040 "none".into()
1041}
1042
1043fn default_reloc_model() -> String {
1044 "pic".into()
1045}
1046
1047#[derive(Eq, PartialEq, Clone, Debug, Default, serde::Deserialize)]
1048#[serde(rename_all = "kebab-case")]
1049pub enum Endian {
1050 #[default]
1051 Little,
1052 Big,
1053}
1054
1055fn builtin_cfg_names(config: &Config) -> HashSet<String> {
1056 rustc_output(
1057 config,
1058 &["--print=check-cfg", "-Zunstable-options", "--check-cfg=cfg()"],
1059 Default::default(),
1060 )
1061 .lines()
1062 .map(|l| if let Some((name, _)) = l.split_once('=') { name.to_string() } else { l.to_string() })
1063 .chain(std::iter::once(String::from("test")))
1064 .collect()
1065}
1066
1067pub const KNOWN_CRATE_TYPES: &[&str] =
1068 &["bin", "cdylib", "dylib", "lib", "proc-macro", "rlib", "staticlib"];
1069
1070fn supported_crate_types(config: &Config) -> HashSet<String> {
1071 let crate_types: HashSet<_> = rustc_output(
1072 config,
1073 &["--target", &config.target, "--print=supported-crate-types", "-Zunstable-options"],
1074 Default::default(),
1075 )
1076 .lines()
1077 .map(|l| l.to_string())
1078 .collect();
1079
1080 for crate_type in crate_types.iter() {
1081 assert!(
1082 KNOWN_CRATE_TYPES.contains(&crate_type.as_str()),
1083 "unexpected crate type `{}`: known crate types are {:?}",
1084 crate_type,
1085 KNOWN_CRATE_TYPES
1086 );
1087 }
1088
1089 crate_types
1090}
1091
1092fn rustc_output(config: &Config, args: &[&str], envs: HashMap<String, String>) -> String {
1093 let mut command = Command::new(&config.rustc_path);
1094 add_dylib_path(&mut command, iter::once(&config.compile_lib_path));
1095 command.args(&config.target_rustcflags).args(args);
1096 command.env("RUSTC_BOOTSTRAP", "1");
1097 command.envs(envs);
1098
1099 let output = match command.output() {
1100 Ok(output) => output,
1101 Err(e) => {
1102 fatal!("failed to run {command:?}: {e}");
1103 }
1104 };
1105 if !output.status.success() {
1106 fatal!(
1107 "failed to run {command:?}\n--- stdout\n{}\n--- stderr\n{}",
1108 String::from_utf8(output.stdout).unwrap(),
1109 String::from_utf8(output.stderr).unwrap(),
1110 );
1111 }
1112 String::from_utf8(output.stdout).unwrap()
1113}
1114
1115fn serde_parse_u32<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u32, D::Error> {
1116 let string = String::deserialize(deserializer)?;
1117 string.parse().map_err(D::Error::custom)
1118}
1119
1120#[derive(Debug, Clone)]
1121pub struct TestPaths {
1122 pub file: Utf8PathBuf, // e.g., compile-test/foo/bar/baz.rs
1123 pub relative_dir: Utf8PathBuf, // e.g., foo/bar
1124}
1125
1126/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
1127pub fn expected_output_path(
1128 testpaths: &TestPaths,
1129 revision: Option<&str>,
1130 compare_mode: &Option<CompareMode>,
1131 kind: &str,
1132) -> Utf8PathBuf {
1133 assert!(UI_EXTENSIONS.contains(&kind));
1134 let mut parts = Vec::new();
1135
1136 if let Some(x) = revision {
1137 parts.push(x);
1138 }
1139 if let Some(ref x) = *compare_mode {
1140 parts.push(x.to_str());
1141 }
1142 parts.push(kind);
1143
1144 let extension = parts.join(".");
1145 testpaths.file.with_extension(extension)
1146}
1147
1148pub const UI_EXTENSIONS: &[&str] = &[
1149 UI_STDERR,
1150 UI_SVG,
1151 UI_WINDOWS_SVG,
1152 UI_STDOUT,
1153 UI_FIXED,
1154 UI_RUN_STDERR,
1155 UI_RUN_STDOUT,
1156 UI_STDERR_64,
1157 UI_STDERR_32,
1158 UI_STDERR_16,
1159 UI_COVERAGE,
1160 UI_COVERAGE_MAP,
1161];
1162pub const UI_STDERR: &str = "stderr";
1163pub const UI_SVG: &str = "svg";
1164pub const UI_WINDOWS_SVG: &str = "windows.svg";
1165pub const UI_STDOUT: &str = "stdout";
1166pub const UI_FIXED: &str = "fixed";
1167pub const UI_RUN_STDERR: &str = "run.stderr";
1168pub const UI_RUN_STDOUT: &str = "run.stdout";
1169pub const UI_STDERR_64: &str = "64bit.stderr";
1170pub const UI_STDERR_32: &str = "32bit.stderr";
1171pub const UI_STDERR_16: &str = "16bit.stderr";
1172pub const UI_COVERAGE: &str = "coverage";
1173pub const UI_COVERAGE_MAP: &str = "cov-map";
1174
1175/// Absolute path to the directory where all output for all tests in the given `relative_dir` group
1176/// should reside. Example:
1177///
1178/// ```text
1179/// /path/to/build/host-tuple/test/ui/relative/
1180/// ```
1181///
1182/// This is created early when tests are collected to avoid race conditions.
1183pub fn output_relative_path(config: &Config, relative_dir: &Utf8Path) -> Utf8PathBuf {
1184 config.build_test_suite_root.join(relative_dir)
1185}
1186
1187/// Generates a unique name for the test, such as `testname.revision.mode`.
1188pub fn output_testname_unique(
1189 config: &Config,
1190 testpaths: &TestPaths,
1191 revision: Option<&str>,
1192) -> Utf8PathBuf {
1193 let mode = config.compare_mode.as_ref().map_or("", |m| m.to_str());
1194 let debugger = config.debugger.as_ref().map_or("", |m| m.to_str());
1195 Utf8PathBuf::from(&testpaths.file.file_stem().unwrap())
1196 .with_extra_extension(config.mode.output_dir_disambiguator())
1197 .with_extra_extension(revision.unwrap_or(""))
1198 .with_extra_extension(mode)
1199 .with_extra_extension(debugger)
1200}
1201
1202/// Absolute path to the directory where all output for the given
1203/// test/revision should reside. Example:
1204/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/
1205pub fn output_base_dir(
1206 config: &Config,
1207 testpaths: &TestPaths,
1208 revision: Option<&str>,
1209) -> Utf8PathBuf {
1210 output_relative_path(config, &testpaths.relative_dir)
1211 .join(output_testname_unique(config, testpaths, revision))
1212}
1213
1214/// Absolute path to the base filename used as output for the given
1215/// test/revision. Example:
1216/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/testname
1217pub fn output_base_name(
1218 config: &Config,
1219 testpaths: &TestPaths,
1220 revision: Option<&str>,
1221) -> Utf8PathBuf {
1222 output_base_dir(config, testpaths, revision).join(testpaths.file.file_stem().unwrap())
1223}
1224
1225/// Absolute path to the directory to use for incremental compilation. Example:
1226/// /path/to/build/host-tuple/test/ui/relative/testname.mode/testname.inc
1227pub fn incremental_dir(
1228 config: &Config,
1229 testpaths: &TestPaths,
1230 revision: Option<&str>,
1231) -> Utf8PathBuf {
1232 output_base_name(config, testpaths, revision).with_extension("inc")
1233}