arch/riscv/kernel/tests/module_test/test_module_linking_main.c
Source file repositories/reference/linux-study-clean/arch/riscv/kernel/tests/module_test/test_module_linking_main.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kernel/tests/module_test/test_module_linking_main.c- Extension
.c- Size
- 1890 bytes
- Lines
- 89
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/init.hkunit/test.h
Detected Declarations
function run_test_setfunction run_test_subfunction run_test_uleb
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2023 Rivos Inc.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <kunit/test.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Test module linking");
extern int test_set32(void);
extern int test_set16(void);
extern int test_set8(void);
extern int test_set6(void);
extern long test_sub64(void);
extern int test_sub32(void);
extern int test_sub16(void);
extern int test_sub8(void);
extern int test_sub6(void);
#ifdef CONFIG_AS_HAS_ULEB128
extern int test_uleb_basic(void);
extern int test_uleb_large(void);
#endif
#define CHECK_EQ(lhs, rhs) KUNIT_ASSERT_EQ(test, lhs, rhs)
void run_test_set(struct kunit *test);
void run_test_sub(struct kunit *test);
void run_test_uleb(struct kunit *test);
void run_test_set(struct kunit *test)
{
int val32 = test_set32();
int val16 = test_set16();
int val8 = test_set8();
int val6 = test_set6();
CHECK_EQ(val32, 0);
CHECK_EQ(val16, 0);
CHECK_EQ(val8, 0);
CHECK_EQ(val6, 0);
}
void run_test_sub(struct kunit *test)
{
int val64 = test_sub64();
int val32 = test_sub32();
int val16 = test_sub16();
int val8 = test_sub8();
int val6 = test_sub6();
CHECK_EQ(val64, 0);
CHECK_EQ(val32, 0);
CHECK_EQ(val16, 0);
CHECK_EQ(val8, 0);
CHECK_EQ(val6, 0);
}
#ifdef CONFIG_AS_HAS_ULEB128
void run_test_uleb(struct kunit *test)
{
int val_uleb = test_uleb_basic();
int val_uleb2 = test_uleb_large();
CHECK_EQ(val_uleb, 0);
CHECK_EQ(val_uleb2, 0);
}
#endif
static struct kunit_case __refdata riscv_module_linking_test_cases[] = {
KUNIT_CASE(run_test_set),
KUNIT_CASE(run_test_sub),
#ifdef CONFIG_AS_HAS_ULEB128
KUNIT_CASE(run_test_uleb),
#endif
{}
};
static struct kunit_suite riscv_module_linking_test_suite = {
.name = "riscv_checksum",
.test_cases = riscv_module_linking_test_cases,
};
kunit_test_suites(&riscv_module_linking_test_suite);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `kunit/test.h`.
- Detected declarations: `function run_test_set`, `function run_test_sub`, `function run_test_uleb`.
- Atlas domain: Architecture Layer / arch/riscv.
- 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.