tools/testing/selftests/exec/non-regular.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/exec/non-regular.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/exec/non-regular.c- Extension
.c- Size
- 3644 bytes
- Lines
- 197
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hfcntl.hstdio.hstring.hunistd.hsys/socket.hsys/stat.hsys/sysmacros.hsys/types.hkselftest_harness.h
Detected Declarations
function rmfunction ASSERT_EQfunction setup_linkfunction setup_dirfunction setup_nodefunction setup_fifo
Annotated Snippet
ASSERT_EQ(errno, ENOENT) {
TH_LOG("Not ENOENT: %s", pathname);
}
} else {
ASSERT_EQ(rc, 0) {
TH_LOG("Failed to remove: %s", pathname);
}
}
}
FIXTURE(file) {
char *pathname;
int is_dir;
};
FIXTURE_VARIANT(file)
{
const char *name;
int expected;
int is_dir;
void (*setup)(struct __test_metadata *_metadata,
FIXTURE_DATA(file) *self,
const FIXTURE_VARIANT(file) *variant);
int major, minor, mode; /* for mknod() */
};
void setup_link(struct __test_metadata *_metadata,
FIXTURE_DATA(file) *self,
const FIXTURE_VARIANT(file) *variant)
{
const char * const paths[] = {
"/bin/true",
"/usr/bin/true",
};
int i;
for (i = 0; i < ARRAY_SIZE(paths); i++) {
if (access(paths[i], X_OK) == 0) {
ASSERT_EQ(symlink(paths[i], self->pathname), 0);
return;
}
}
ASSERT_EQ(1, 0) {
TH_LOG("Could not find viable 'true' binary");
}
}
FIXTURE_VARIANT_ADD(file, S_IFLNK)
{
.name = "S_IFLNK",
.expected = ELOOP,
.setup = setup_link,
};
void setup_dir(struct __test_metadata *_metadata,
FIXTURE_DATA(file) *self,
const FIXTURE_VARIANT(file) *variant)
{
ASSERT_EQ(mkdir(self->pathname, 0755), 0);
}
FIXTURE_VARIANT_ADD(file, S_IFDIR)
{
.name = "S_IFDIR",
.is_dir = 1,
.expected = EACCES,
.setup = setup_dir,
};
void setup_node(struct __test_metadata *_metadata,
FIXTURE_DATA(file) *self,
const FIXTURE_VARIANT(file) *variant)
{
dev_t dev;
int rc;
dev = makedev(variant->major, variant->minor);
rc = mknod(self->pathname, 0755 | variant->mode, dev);
ASSERT_EQ(rc, 0) {
if (errno == EPERM)
SKIP(return, "Please run as root; cannot mknod(%s)",
variant->name);
}
}
FIXTURE_VARIANT_ADD(file, S_IFBLK)
{
.name = "S_IFBLK",
.expected = EACCES,
.setup = setup_node,
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `stdio.h`, `string.h`, `unistd.h`, `sys/socket.h`, `sys/stat.h`, `sys/sysmacros.h`.
- Detected declarations: `function rm`, `function ASSERT_EQ`, `function setup_link`, `function setup_dir`, `function setup_node`, `function setup_fifo`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.