selftests/bpf: Add __arch_loongarch to limit test cases for LoongArch

Make it possible to limit certain tests to LoongArch, just like it is
already done for x86_64, arm64, riscv64, and s390x.

This is a follow up patch of:

  commit ee7fe84468 ("selftests/bpf: __arch_* macro to limit test cases to specific archs")
  commit 1e4e6b9e26 ("selftests/bpf: Add __arch_s390x macro")

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
Tiezhu Yang 2026-06-25 13:08:57 +08:00 committed by Huacai Chen
parent edc5cb8b2b
commit d5381d2dd4
2 changed files with 6 additions and 0 deletions

View File

@ -158,6 +158,7 @@
#define __arch_arm64 __arch("ARM64")
#define __arch_riscv64 __arch("RISCV64")
#define __arch_s390x __arch("s390x")
#define __arch_loongarch __arch("LOONGARCH")
#define __caps_unpriv(caps) __test_tag("test_caps_unpriv=" EXPAND_QUOTE(caps))
#define __load_if_JITed() __test_tag("load_mode=jited")
#define __load_if_no_JITed() __test_tag("load_mode=no_jited")

View File

@ -377,6 +377,7 @@ enum arch {
ARCH_ARM64 = 0x4,
ARCH_RISCV64 = 0x8,
ARCH_S390X = 0x10,
ARCH_LOONGARCH = 0x20,
};
static int get_current_arch(void)
@ -389,6 +390,8 @@ static int get_current_arch(void)
return ARCH_RISCV64;
#elif defined(__s390x__)
return ARCH_S390X;
#elif defined(__loongarch__)
return ARCH_LOONGARCH;
#endif
return ARCH_UNKNOWN;
}
@ -580,6 +583,8 @@ static int parse_test_spec(struct test_loader *tester,
arch = ARCH_RISCV64;
} else if (strcmp(val, "s390x") == 0) {
arch = ARCH_S390X;
} else if (strcmp(val, "LOONGARCH") == 0) {
arch = ARCH_LOONGARCH;
} else {
PRINT_FAIL("bad arch spec: '%s'\n", val);
err = -EINVAL;