scripts/rust_is_available_test.py
Source file repositories/reference/linux-study-clean/scripts/rust_is_available_test.py
File Facts
- System
- Linux kernel
- Corpus path
scripts/rust_is_available_test.py- Extension
.py- Size
- 17794 bytes
- Lines
- 342
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""Tests the `rust_is_available.sh` script.
Some of the tests require the real programs to be available in `$PATH`
under their canonical name (and with the expected versions).
"""
import enum
import os
import pathlib
import stat
import subprocess
import tempfile
import unittest
class TestRustIsAvailable(unittest.TestCase):
@enum.unique
class Expected(enum.Enum):
SUCCESS = enum.auto()
SUCCESS_WITH_WARNINGS = enum.auto()
SUCCESS_WITH_EXTRA_OUTPUT = enum.auto()
FAILURE = enum.auto()
@classmethod
def generate_executable(cls, content):
path = pathlib.Path(cls.tempdir.name)
name = str(len(tuple(path.iterdir())))
path = path / name
with open(path, "w") as file_:
file_.write(content)
os.chmod(path, os.stat(path).st_mode | stat.S_IXUSR)
return path
@classmethod
def generate_clang(cls, stdout):
return cls.generate_executable(f"""#!/usr/bin/env python3
import sys
if "-E" in " ".join(sys.argv):
print({repr("Clang " + " ".join(cls.llvm_default_version.split(" ")))})
else:
print({repr(stdout)})
""")
@classmethod
def generate_rustc(cls, stdout):
return cls.generate_executable(f"""#!/usr/bin/env python3
import sys
if "--print sysroot" in " ".join(sys.argv):
print({repr(cls.rust_default_sysroot)})
else:
print({repr(stdout)})
""")
@classmethod
def generate_bindgen(cls, version_stdout, libclang_stderr):
if libclang_stderr is None:
libclang_case = f"raise SystemExit({cls.bindgen_default_bindgen_libclang_failure_exit_code})"
else:
libclang_case = f"print({repr(libclang_stderr)}, file=sys.stderr)"
return cls.generate_executable(f"""#!/usr/bin/env python3
import sys
if "rust_is_available_bindgen_libclang.h" in " ".join(sys.argv):
{libclang_case}
else:
print({repr(version_stdout)})
""")
Annotation
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.