Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | tools/testing/selftests/breakpoints/breakpoint_test.c | static void dummy_func3(void) {} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/breakpoints/breakpoint_test.c | static void check_trapped(void) {
if (!trapped)
kill(getpid(), SIGUSR1);
trapped = 0;
nr_tests++;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/breakpoints/breakpoint_test.c |
static void launch_watchpoints(char *buf, int mode, int len, int local,
int global) {
const char *mode_str;
int i;
if (mode == BP_W)
mode_str = "write";
else
mode_str = "read";
for (i = 0; i < COUNT_WPS; i++) {
set_breakpoint_addr(&dummy_var[i], i);
toggle_bre... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/breakpoints/breakpoint_test.c |
int main(int argc, char **argv) {
pid_t pid;
int ret;
ksft_print_header();
pid = fork();
if (!pid) {
trigger_tests();
exit(0);
}
child_pid = pid;
wait(NULL);
launch_tests();
wait(NULL);
ksft_exit_pass();
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/breakpoints/breakpoint_test_arm64.c | static bool set_watchpoint(pid_t pid, int size, int wp) {
const volatile uint8_t *addr = &var[32 + wp];
const int offset = (uintptr_t)addr % 8;
const unsigned int byte_mask = ((1 << size) - 1) << offset;
const unsigned int type = 2;
const unsigned int enable = 1;
const unsigned int control = byte_mask << 5 ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/breakpoints/step_after_suspend_test.c |
int main(int argc, char **argv) {
int opt;
bool do_suspend = true;
bool succeeded = true;
unsigned int tests = 0;
cpu_set_t available_cpus;
int err;
int cpu;
ksft_print_header();
while ((opt = getopt(argc, argv, "n")) != -1) {
switch (opt) {
case 'n':
do_suspend = false;
break;
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/capabilities/test_execve.c |
static void maybe_write_file(char *filename, char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vmaybe_write_file(true, filename, fmt, ap);
va_end(ap);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/capabilities/test_execve.c |
static void write_file(char *filename, char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vmaybe_write_file(false, filename, fmt, ap);
va_end(ap);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/capabilities/test_execve.c | static void copy_fromat_to(int fromfd, const char *fromname,
const char *toname) {
int from = openat(fromfd, fromname, O_RDONLY);
if (from == -1)
ksft_exit_fail_msg("open copy source - %s\n", strerror(errno));
int to = open(toname, O_CREAT | O_WRONLY | O_EXCL, 0700);
while (true... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/capabilities/test_execve.c |
static void exec_validate_cap(bool eff, bool perm, bool inh, bool ambient) {
exec_other_validate_cap("./validate_cap", eff, perm, inh, ambient);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/capabilities/validate_cap.c | int main(int argc, char **argv) {
const char *atsec = "";
if (argc != 5)
ksft_exit_fail_msg("wrong argc\n");
#ifdef HAVE_GETAUXVAL
if (getauxval(AT_SECURE))
atsec = " (AT_SECURE is set)";
else
atsec = " (AT_SECURE is not set)";
#endif
capng_get_caps_process();
if (capng_have_capability(CAPNG... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c | static ssize_t read_text(const char *path, char *buf, size_t max_len) {
ssize_t len;
int fd;
fd = open(path, O_RDONLY);
if (fd < 0)
return -errno;
len = read(fd, buf, max_len - 1);
if (len >= 0)
buf[len] = 0;
close(fd);
return len < 0 ? -errno : len;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c |
char *cg_name_indexed(const char *root, const char *name, int index) {
size_t len = strlen(root) + strlen(name) + 10;
char *ret = malloc(len);
snprintf(ret, len, "%s/%s_%d", root, name, index);
return ret;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c | int cg_read_strcmp(const char *cgroup, const char *control,
const char *expected) {
size_t size;
char *buf;
int ret;
if (!expected)
return -1;
else
size = strlen(expected) + 1;
buf = malloc(size);
if (!buf)
return -1;
if (cg_read(cgroup, control, buf, size)) {
free(... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c | int cg_find_unified_root(char *root, size_t len) {
char buf[10 * PAGE_SIZE];
char *fs, *mount, *type;
const char delim[] = "\n\t ";
if (read_text("/proc/self/mounts", buf, sizeof(buf)) <= 0)
return -1;
for (fs = strtok(buf, delim); fs; fs = strtok(NULL, delim)) {
mount = strtok(NULL, delim);
typ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c |
int cg_create(const char *cgroup) { return mkdir(cgroup, 0755); } | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c |
int cg_wait_for_proc_count(const char *cgroup, int count) {
char buf[10 * PAGE_SIZE] = {0};
int attempts;
char *ptr;
for (attempts = 10; attempts >= 0; attempts--) {
int nr = 0;
if (cg_read(cgroup, "cgroup.procs", buf, sizeof(buf)))
break;
for (ptr = buf; *ptr; ptr++)
if (*ptr == '\n... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c | pid_t clone_into_cgroup(int cgroup_fd) {
#ifdef CLONE_ARGS_SIZE_VER2
pid_t pid;
struct __clone_args args = {
.flags = CLONE_INTO_CGROUP,
.exit_signal = SIGCHLD,
.cgroup = cgroup_fd,
};
pid = sys_clone3(&args, sizeof(struct __clone_args));
if (pid < 0 && (errno == ENOSYS || errno == E2BIG)... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c |
int dirfd_open_opath(const char *dir) {
return open(dir, O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW | O_PATH);
}
#define close_prot_errno(fd) \
if (fd >= 0) { \
int _e_ = errno; ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c | int cg_run_nowait(const char *cgroup, int (*fn)(const char *cgroup, void *arg),
void *arg) {
int pid;
pid = clone_into_cgroup_run_nowait(cgroup, fn, arg);
if (pid > 0)
return pid;
if (pid < 0 && errno != ENOSYS)
return -1;
pid = fork();
if (pid == 0) {
char buf[64];
snp... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/cgroup_util.c |
int proc_mount_contains(const char *option) {
char buf[4 * PAGE_SIZE];
ssize_t read;
read = read_text("/proc/mounts", buf, sizeof(buf));
if (read < 0)
return read;
return strstr(buf, option) != NULL;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c | static int test_cgcore_invalid_domain(const char *root) {
int ret = KSFT_FAIL;
char *grandparent = NULL, *parent = NULL, *child = NULL;
grandparent = cg_name(root, "cg_test_grandparent");
parent = cg_name(root, "cg_test_grandparent/cg_test_parent");
child = cg_name(root, "cg_test_grandparent/cg_test_parent/c... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c | static int
test_cgcore_no_internal_process_constraint_on_threads(const char *root) {
int ret = KSFT_FAIL;
char *parent = NULL, *child = NULL;
if (cg_read_strstr(root, "cgroup.controllers", "cpu") ||
cg_write(root, "cgroup.subtree_control", "+cpu")) {
ret = KSFT_SKIP;
goto cleanup;
}
parent = c... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c | static int test_cgcore_top_down_constraint_disable(const char *root) {
int ret = KSFT_FAIL;
char *parent = NULL, *child = NULL;
parent = cg_name(root, "cg_test_parent");
child = cg_name(root, "cg_test_parent/cg_test_child");
if (!parent || !child)
goto cleanup;
if (cg_create(parent))
goto cleanup;... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c | static int test_cgcore_proc_migration(const char *root) {
int ret = KSFT_FAIL;
int t, c_threads = 0, n_threads = 13;
char *src = NULL, *dst = NULL;
pthread_t threads[n_threads];
src = cg_name(root, "cg_src");
dst = cg_name(root, "cg_dst");
if (!src || !dst)
goto cleanup;
if (cg_create(src))
go... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c |
static void *migrating_thread_fn(void *arg) {
int g, i, n_iterations = 1000;
char **grps = arg;
char lines[3][PATH_MAX];
for (g = 1; g < 3; ++g)
snprintf(lines[g], sizeof(lines[g]), "0::%s", grps[g] + strlen(grps[0]));
for (i = 0; i < n_iterations; ++i) {
cg_enter_current_thread(grps[(i % 2) + 1]);... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c | static int test_cgcore_thread_migration(const char *root) {
int ret = KSFT_FAIL;
char *dom = NULL;
char line[PATH_MAX];
char *grps[3] = {(char *)root, NULL, NULL};
pthread_t thr;
void *retval;
dom = cg_name(root, "cg_dom");
grps[1] = cg_name(root, "cg_dom/cg_src");
grps[2] = cg_name(root, "cg_dom/cg_... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_core.c | static int test_cgcore_lesser_euid_open(const char *root) {
const uid_t test_euid = 65534;
int ret = KSFT_FAIL;
char *cg_test_a = NULL, *cg_test_b = NULL;
char *cg_test_a_procs = NULL, *cg_test_b_procs = NULL;
int cg_test_b_procs_fd = -1;
uid_t saved_uid;
cg_test_a = cg_name(root, "cg_test_a");
cg_test... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_cpu.c |
static int overprovision_validate(const struct cpu_hogger *children,
int num_children) {
int ret = KSFT_FAIL, i;
for (i = 0; i < num_children - 1; i++) {
long delta;
if (children[i + 1].usage <= children[i].usage)
goto cleanup;
delta = children[i + 1].usage - ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_cpu.c |
static pid_t weight_hog_one_cpu(const struct cpu_hogger *child) {
return weight_hog_ncpus(child, 1);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_cpu.c |
static int underprovision_validate(const struct cpu_hogger *children,
int num_children) {
int ret = KSFT_FAIL, i;
for (i = 0; i < num_children - 1; i++) {
if (!values_close(children[i + 1].usage, children[0].usage, 15))
goto cleanup;
}
ret = KSFT_PASS;
cleanup:
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int cg_enter_and_wait_for_frozen(const char *cgroup, int pid,
bool frozen) {
int fd, ret = -1;
int attempts;
fd = cg_prepare_for_wait(cgroup);
if (fd < 0)
return fd;
ret = cg_enter(cgroup, pid);
if (ret)
goto out;
for (attempts = 0; attempts < 10; ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int forkbomb_fn(const char *cgroup, void *arg) {
int ppid;
fork();
fork();
ppid = getppid();
while (getppid() == ppid)
usleep(1000);
return getppid() == ppid;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int test_cgfreezer_mkdir(const char *root) {
int ret = KSFT_FAIL;
char *parent, *child = NULL;
int pid;
parent = cg_name(root, "cg_test_mkdir_A");
if (!parent)
goto cleanup;
child = cg_name(parent, "cg_test_mkdir_B");
if (!child)
goto cleanup;
if (cg_create(parent))
goto cleanup;
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int test_cgfreezer_rmdir(const char *root) {
int ret = KSFT_FAIL;
char *parent, *child = NULL;
parent = cg_name(root, "cg_test_rmdir_A");
if (!parent)
goto cleanup;
child = cg_name(parent, "cg_test_rmdir_B");
if (!child)
goto cleanup;
if (cg_create(parent))
goto cleanup;
if (cg_cr... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int test_cgfreezer_ptrace(const char *root) {
int ret = KSFT_FAIL;
char *cgroup = NULL;
siginfo_t siginfo;
int pid;
cgroup = cg_name(root, "cg_test_ptrace");
if (!cgroup)
goto cleanup;
if (cg_create(cgroup))
goto cleanup;
pid = cg_run_nowait(cgroup, child_fn, NULL);
if (pid < 0)
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int test_cgfreezer_stopped(const char *root) {
int pid, ret = KSFT_FAIL;
char *cgroup = NULL;
cgroup = cg_name(root, "cg_test_stopped");
if (!cgroup)
goto cleanup;
if (cg_create(cgroup))
goto cleanup;
pid = cg_run_nowait(cgroup, child_fn, NULL);
if (cg_wait_for_proc_count(cgroup, 1))
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c | static int test_cgfreezer_ptraced(const char *root) {
int pid, ret = KSFT_FAIL;
char *cgroup = NULL;
siginfo_t siginfo;
cgroup = cg_name(root, "cg_test_ptraced");
if (!cgroup)
goto cleanup;
if (cg_create(cgroup))
goto cleanup;
pid = cg_run_nowait(cgroup, child_fn, NULL);
if (cg_wait_for_proc... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_freezer.c |
int main(int argc, char *argv[]) {
char root[PATH_MAX];
int i, ret = EXIT_SUCCESS;
if (cg_find_unified_root(root, sizeof(root)))
ksft_exit_skip("cgroup v2 isn't mounted\n");
for (i = 0; i < ARRAY_SIZE(tests); i++) {
switch (tests[i].fn(root)) {
case KSFT_PASS:
ksft_test_result_pass("%s\n", t... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kill.c | static int cg_kill_wait(const char *cgroup) {
int fd, ret = -1;
fd = cg_prepare_for_wait(cgroup);
if (fd < 0)
return fd;
ret = cg_write(cgroup, "cgroup.kill", "1");
if (ret)
goto out;
ret = cg_wait_for(fd);
if (ret)
goto out;
out:
close(fd);
return ret;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kill.c | static int child_fn(const char *cgroup, void *arg) {
int ppid = getppid();
while (getppid() == ppid)
usleep(1000);
return getppid() == ppid;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kill.c |
static int test_cgkill_simple(const char *root) {
pid_t pids[100];
int ret = KSFT_FAIL;
char *cgroup = NULL;
int i;
cgroup = cg_name(root, "cg_test_simple");
if (!cgroup)
goto cleanup;
if (cg_create(cgroup))
goto cleanup;
for (i = 0; i < 100; i++)
pids[i] = cg_run_nowait(cgroup, child_fn... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kmem.c |
static void *alloc_kmem_fn(void *arg) {
alloc_dcache(NULL, (void *)100);
return NULL;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kmem.c |
static int spawn_1000_threads(const char *cgroup, void *arg) {
int nr_threads = 1000;
pthread_t *tinfo;
unsigned long i;
long stack;
int ret = -1;
tinfo = calloc(nr_threads, sizeof(pthread_t));
if (tinfo == NULL)
return -1;
for (i = 0; i < nr_threads; i++) {
if (pthread_create(&tinfo[i], NULL... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kmem.c | static int test_kmem_kernel_stacks(const char *root) {
int ret = KSFT_FAIL;
char *cg = NULL;
cg = cg_name(root, "kmem_kernel_stacks_test");
if (!cg)
goto cleanup;
if (cg_create(cg))
goto cleanup;
if (cg_run(cg, spawn_1000_threads, NULL))
goto cleanup;
ret = KSFT_PASS;
cleanup:
cg_destroy... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kmem.c | static int test_kmem_dead_cgroups(const char *root) {
int ret = KSFT_FAIL;
char *parent;
long dead;
int i;
parent = cg_name(root, "kmem_dead_cgroups_test");
if (!parent)
goto cleanup;
if (cg_create(parent))
goto cleanup;
if (cg_write(parent, "cgroup.subtree_control", "+memory"))
goto clea... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_kmem.c | int main(int argc, char **argv) {
char root[PATH_MAX];
int i, ret = EXIT_SUCCESS;
if (cg_find_unified_root(root, sizeof(root)))
ksft_exit_skip("cgroup v2 isn't mounted\n");
if (cg_read_strstr(root, "cgroup.controllers", "memory"))
ksft_exit_skip("memory controller isn't available\n");
if (cg_read_s... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c |
static int alloc_pagecache_50M_noexit(const char *cgroup, void *arg) {
int fd = (long)arg;
int ppid = getppid();
if (alloc_pagecache(fd, MB(50)))
return -1;
while (getppid() == ppid)
sleep(1);
return 0;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c |
static int alloc_anon_noexit(const char *cgroup, void *arg) {
int ppid = getppid();
size_t size = (unsigned long)arg;
char *buf, *ptr;
buf = malloc(size);
for (ptr = buf; ptr < buf + size; ptr += PAGE_SIZE)
*ptr = 0;
while (getppid() == ppid)
sleep(1);
free(buf);
return 0;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c |
static int test_memcg_min(const char *root) {
return test_memcg_protection(root, true);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c | static int test_memcg_high_sync(const char *root) {
int ret = KSFT_FAIL, pid, fd = -1;
char *memcg;
long pre_high, pre_max;
long post_high, post_max;
memcg = cg_name(root, "memcg_test");
if (!memcg)
goto cleanup;
if (cg_create(memcg))
goto cleanup;
pre_high = cg_read_key_long(memcg, "memory.e... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c | static bool reclaim_until(const char *memcg, long goal) {
char buf[64];
int retries, err;
long current, to_reclaim;
bool reclaimed = false;
for (retries = 5; retries > 0; retries--) {
current = cg_read_long(memcg, "memory.current");
if (current < goal || values_close(current, goal, 3))
break;
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c | static int test_memcg_oom_events(const char *root) {
int ret = KSFT_FAIL;
char *memcg;
memcg = cg_name(root, "memcg_test");
if (!memcg)
goto cleanup;
if (cg_create(memcg))
goto cleanup;
if (cg_write(memcg, "memory.max", "30M"))
goto cleanup;
if (cg_write(memcg, "memory.swap.max", "0"))
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c | static int test_memcg_sock(const char *root) {
int bind_retries = 5, ret = KSFT_FAIL, pid, err;
unsigned short port;
char *memcg;
memcg = cg_name(root, "memcg_test");
if (!memcg)
goto cleanup;
if (cg_create(memcg))
goto cleanup;
while (bind_retries--) {
struct tcp_server_args args;
if ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c | static int test_memcg_oom_group_parent_events(const char *root) {
int ret = KSFT_FAIL;
char *parent, *child;
parent = cg_name(root, "memcg_test_0");
child = cg_name(root, "memcg_test_0/memcg_test_1");
if (!parent || !child)
goto cleanup;
if (cg_create(parent))
goto cleanup;
if (cg_create(child... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/cgroup/test_memcontrol.c | int main(int argc, char **argv) {
char root[PATH_MAX];
int i, proc_status, ret = EXIT_SUCCESS;
if (cg_find_unified_root(root, sizeof(root)))
ksft_exit_skip("cgroup v2 isn't mounted\n");
if (cg_read_strstr(root, "cgroup.controllers", "memory"))
ksft_exit_skip("memory controller isn't available\n");
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c |
static int call_clone3_set_tid(struct __test_metadata *_metadata,
pid_t *set_tid, size_t set_tid_size) {
int status;
pid_t pid = -1;
struct __clone_args args = {
.exit_signal = SIGCHLD,
.set_tid = ptr_to_u64(set_tid),
.set_tid_size = set_tid_size,
};
pid = s... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c | static int set_capability(void) {
cap_value_t cap_values[] = {CAP_SETUID, CAP_SETGID};
struct libcap *cap;
int ret = -1;
cap_t caps;
caps = cap_get_proc();
if (!caps) {
perror("cap_get_proc");
return -1;
}
if (cap_clear(caps)) {
perror("cap_clear");
goto out;
}
cap_set_flag(caps, ... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/clone3/clone3_clear_sighand.c |
static void nop_handler(int signo) {} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c |
static int import_vgem_fd(int vgem_fd, int dma_buf_fd, uint32_t *handle) {
struct drm_prime_handle import_handle = {
.fd = dma_buf_fd,
.flags = 0,
.handle = 0,
};
int ret;
ret = ioctl(vgem_fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &import_handle);
if (ret == 0)
*handle = import_handle.handle;
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c |
static void close_handle(int vgem_fd, uint32_t handle) {
struct drm_gem_close close = {
.handle = handle,
};
ioctl(vgem_fd, DRM_IOCTL_GEM_CLOSE, &close);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c |
static int dmabuf_heap_alloc_fdflags(int fd, size_t len, unsigned int fd_flags,
unsigned int heap_flags, int *dmabuf_fd) {
struct dma_heap_allocation_data data = {
.len = len,
.fd = 0,
.fd_flags = fd_flags,
.heap_flags = heap_flags,
};
int ret;
if (... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c |
static int dmabuf_sync(int fd, int start_stop) {
struct dma_buf_sync sync = {
.flags = start_stop | DMA_BUF_SYNC_RW,
};
return ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c |
int main(void) {
DIR *d;
struct dirent *dir;
int ret = -1;
d = opendir(DEVPATH);
if (!d) {
printf("No %s directory?\n", DEVPATH);
return -1;
}
while ((dir = readdir(d)) != NULL) {
if (!strncmp(dir->d_name, ".", 2))
continue;
if (!strncmp(dir->d_name, "..", 3))
continue;
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/drivers/dma-buf/udmabuf.c |
static int memfd_create(const char *name, unsigned int flags) {
return syscall(__NR_memfd_create, name, flags);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/efivarfs/create-read.c | int main(int argc, char **argv) {
const char *path;
char buf[4];
int fd, rc;
if (argc < 2) {
fprintf(stderr, "usage: %s <path>\n", argv[0]);
return EXIT_FAILURE;
}
path = argv[1];
fd = open(path, O_RDWR | O_CREAT, 0600);
if (fd < 0) {
perror("open(O_WRONLY)");
return EXIT_FAILURE;
}... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/exec/execveat.c | static int check_execveat_invoked_rc(int fd, const char *path, int flags,
int expected_rc, int expected_rc2) {
int status;
int rc;
pid_t child;
int pathlen = path ? strlen(path) : 0;
if (pathlen > 40)
printf("Check success of execveat(%d, '%.20s...%s', %d)... ", fd, p... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/binderfs/binderfs_test.c | static void *binder_version_thread(void *data) {
struct __test_metadata *_metadata = _thread_metadata;
int fd = PTR_TO_INT(data);
struct binder_version version = {0};
int ret;
ret = ioctl(fd, BINDER_VERSION, &version);
if (ret < 0)
TH_LOG("%s - Failed to open perform BINDER_VERSION request\n",
... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/devpts_pts.c |
int main(int argc, char *argv[]) {
int ret;
if (!isatty(STDIN_FILENO)) {
fprintf(stderr, "Standard input file descriptor is not attached "
"to a terminal. Skipping test\n");
exit(KSFT_SKIP);
}
ret = unshare(CLONE_NEWNS);
if (ret < 0) {
fprintf(stderr, "Failed to unshare moun... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/dnotify_test.c | int main(void) {
struct sigaction act;
int fd;
act.sa_sigaction = handler;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
sigaction(SIGRTMIN + 1, &act, NULL);
fd = open(".", O_RDONLY);
fcntl(fd, F_SETSIG, SIGRTMIN + 1);
fcntl(fd, F_NOTIFY, DN_MODIFY | DN_CREATE | DN_MULTISHOT);
while (1) {... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c |
static void signal_handler(int signum) {} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c |
static void *waiter_entry1ap(void *data) {
struct pollfd pfd;
struct epoll_event e;
struct epoll_mtcontext *ctx = data;
pfd.fd = ctx->efd[0];
pfd.events = POLLIN;
if (poll(&pfd, 1, -1) > 0) {
if (epoll_wait(ctx->efd[0], &e, 1, 0) > 0)
__sync_fetch_and_add(&ctx->count, 1);
}
return NULL;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c |
static void *waiter_entry2ap(void *data) {
struct pollfd pfd;
struct epoll_event events[2];
struct epoll_mtcontext *ctx = data;
pfd.fd = ctx->efd[0];
pfd.events = POLLIN;
if (poll(&pfd, 1, -1) > 0) {
if (epoll_wait(ctx->efd[0], events, 2, 0) > 0)
__sync_fetch_and_add(&ctx->count, 1);
}
retu... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c |
static void *emitter_entry1(void *data) {
struct epoll_mtcontext *ctx = data;
usleep(100000);
write(ctx->sfd[1], "w", 1);
kill_timeout(ctx);
return NULL;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c | static void *epoll61_epoll_with_timeout(void *ctx_) {
struct epoll61_ctx *ctx = ctx_;
struct epoll_event events[1];
int n;
n = epoll_wait(ctx->epfd, events, 1, 11);
if (n == 1) {
int64_t l = 1;
write(ctx->evfd, &l, sizeof(l));
}
return NULL;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/firmware/fw_namespace.c | int main(int argc, char **argv) {
const char *fw_name = "test-firmware.bin";
char *sys_path;
if (argc != 2)
die("usage: %s sys_path\n", argv[0]);
if (mount("test", "/lib/firmware", "tmpfs", 0, NULL) == -1)
die("mounting tmpfs to /lib/firmware failed\n");
sys_path = argv[1];
if (asprintf(&fw_path, ... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_requeue.c |
void usage(char *prog) {
printf("Usage: %s\n", prog);
printf(" -c Use color\n");
printf(" -h Display this help message\n");
printf(" -v L Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
VQUIET, VCRITICAL, VINFO);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_requeue_pi.c |
void *third_party_blocker(void *arg) {
struct thread_arg *args = (struct thread_arg *)arg;
int ret2 = 0;
args->ret = futex_lock_pi(&f2, NULL, 0, FUTEX_PRIVATE_FLAG);
if (args->ret)
goto out;
args->ret =
futex_wait(&wake_complete, wake_complete, NULL, FUTEX_PRIVATE_FLAG);
ret2 = futex_unlock_pi(&... | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_requeue_pi.c | int main(int argc, char *argv[]) {
int c, ret;
while ((c = getopt(argc, argv, "bchlot:v:")) != -1) {
switch (c) {
case 'b':
broadcast = 1;
break;
case 'c':
log_color(1);
break;
case 'h':
usage(basename(argv[0]));
exit(0);
case 'l':
locked = 1;
bre... | [
1,
1
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_requeue_pi_mismatched_ops.c |
void usage(char *prog) {
printf("Usage: %s\n", prog);
printf(" -c Use color\n");
printf(" -h Display this help message\n");
printf(" -v L Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
VQUIET, VCRITICAL, VINFO);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c |
void handle_signal(int signo) {
info("signal received %s requeue\n", requeued.val ? "after" : "prior to");
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_requeue_pi_signal_restart.c |
void *waiterfn(void *arg) {
unsigned int old_val;
int res;
waiter_ret = RET_PASS;
info("Waiter running\n");
info("Calling FUTEX_LOCK_PI on f2=%x @ %p\n", f2, &f2);
old_val = f1;
res = futex_wait_requeue_pi(&f1, old_val, &(f2), NULL, FUTEX_PRIVATE_FLAG);
if (!requeued.val || errno != EWOULDBLOCK) {
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_waitv.c |
void usage(char *prog) {
printf("Usage: %s\n", prog);
printf(" -c Use color\n");
printf(" -h Display this help message\n");
printf(" -v L Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
VQUIET, VCRITICAL, VINFO);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_waitv.c | void *waiterfn(void *arg) {
struct timespec to;
int res;
if (clock_gettime(CLOCK_MONOTONIC, &to))
error("gettime64 failed\n", errno);
to.tv_sec++;
res = futex_waitv(waitv, NR_FUTEXES, 0, &to, CLOCK_MONOTONIC);
if (res < 0) {
ksft_test_result_fail("futex_waitv returned: %d %s\n", errno,
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_wait_timeout.c |
void usage(char *prog) {
printf("Usage: %s\n", prog);
printf(" -c Use color\n");
printf(" -h Display this help message\n");
printf(" -t N Timeout in nanoseconds (default: 100,000)\n");
printf(" -v L Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
VQUIET, VCRITICAL, VINFO);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_wait_timeout.c | static void test_timeout(int res, int *ret, char *test_name, int err) {
if (!res || errno != err) {
ksft_test_result_fail("%s returned %d\n", test_name, res < 0 ? errno : res);
*ret = RET_FAIL;
} else {
ksft_test_result_pass("%s succeeds\n", test_name);
}
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_wait_uninitialized_heap.c |
void *wait_thread(void *arg) {
int res;
child_ret = RET_PASS;
res = futex_wait(buf, 1, NULL, 0);
child_blocked = 0;
if (res != 0 && errno != EWOULDBLOCK) {
error("futex failure\n", errno);
child_ret = RET_ERROR;
}
pthread_exit(NULL);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/functional/futex_wait_wouldblock.c |
void usage(char *prog) {
printf("Usage: %s\n", prog);
printf(" -c Use color\n");
printf(" -h Display this help message\n");
printf(" -v L Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
VQUIET, VCRITICAL, VINFO);
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/futex/include/atomic.h | static inline int atomic_dec(atomic_t *addr) {
return __sync_sub_and_fetch(&addr->val, 1);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/include/futex2test.h | static inline int futex_waitv(volatile struct futex_waitv *waiters,
unsigned long nr_waiters, unsigned long flags,
struct timespec *timo, clockid_t clockid) {
return syscall(__NR_futex_waitv, waiters, nr_waiters, flags, timo, clockid);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/include/futextest.h | static inline int futex_wake(futex_t *uaddr, int nr_wake, int opflags) {
return futex(uaddr, FUTEX_WAKE, nr_wake, NULL, NULL, 0, opflags);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/include/futextest.h | static inline int futex_wait_requeue_pi(futex_t *uaddr, futex_t val,
futex_t *uaddr2,
struct timespec *timeout, int opflags) {
return futex(uaddr, FUTEX_WAIT_REQUEUE_PI, val, timeout, uaddr2, 0, opflags);
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/include/futextest.h | static inline u_int32_t futex_set(futex_t *uaddr, u_int32_t newval) {
*uaddr = newval;
return newval;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/futex/include/logging.h | void log_verbosity(int level) {
if (level > VMAX)
level = VMAX;
else if (level < 0)
level = 0;
_verbose = level;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/gpio/gpio-line-name.c |
int main(int argc, char **argv) {
struct gpio_v2_line_info info;
int fd, ret;
char *endp;
if (argc != 3) {
print_usage();
return EXIT_FAILURE;
}
fd = open(argv[1], O_RDWR);
if (fd < 0) {
perror("unable to open the GPIO chip");
return EXIT_FAILURE;
}
memset(&info, 0, sizeof(info));
... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/gpio/gpio-mockup-cdev.c |
static int get_value_v2(int lfd) {
struct gpio_v2_line_values vals;
int ret;
memset(&vals, 0, sizeof(vals));
vals.mask = 1;
ret = ioctl(lfd, GPIO_V2_LINE_GET_VALUES_IOCTL, &vals);
if (ret == -1)
return -errno;
return vals.bits & 0x1;
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/gpio/gpio-mockup-cdev.c |
static int request_line_v1(int cfd, unsigned int offset, uint32_t flags,
unsigned int val) {
struct gpiohandle_request req;
int ret;
memset(&req, 0, sizeof(req));
req.lines = 1;
req.lineoffsets[0] = offset;
req.flags = flags;
strcpy(req.consumer_label, CONSUMER);
if (flags &... | [
1,
0
] |
Linux Kernel | tools/testing/selftests/gpio/gpio-mockup-cdev.c |
static int get_value_v1(int lfd) {
struct gpiohandle_data vals;
int ret;
memset(&vals, 0, sizeof(vals));
ret = ioctl(lfd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, &vals);
if (ret == -1)
return -errno;
return vals.values[0];
} | [
1,
0
] |
Linux Kernel | tools/testing/selftests/gpio/gpio-mockup-cdev.c |
static int wait_signal(void) {
int sig;
sigset_t wset;
sigemptyset(&wset);
sigaddset(&wset, SIGHUP);
sigaddset(&wset, SIGINT);
sigaddset(&wset, SIGTERM);
sigwait(&wset, &sig);
return sig;
} | [
0,
0
] |
Linux Kernel | tools/testing/selftests/ia64/aliasing-test.c |
static int scan_tree(char *path, char *file, off_t offset, size_t length,
int touch) {
struct dirent **namelist;
char *name, *path2;
int i, n, r, rc = 0, result = 0;
struct stat buf;
n = scandir(path, &namelist, 0, alphasort);
if (n < 0) {
perror("scandir");
return -1;
}
... | [
1,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.