Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/testing/selftests/safesetid/safesetid-test.c
static bool test_userns(bool expect_success) { uid_t uid; char map_file_name[32]; size_t sz = sizeof(map_file_name); pid_t cpid; bool success; uid = getuid(); int clone_flags = CLONE_NEWUSER; cpid = syscall(SYS_clone, clone_flags, NULL); if (cpid == -1) { printf("clone failed"); return false...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/safesetid/safesetid-test.c
static void ensure_users_exist(void) { ensure_user_exists(ROOT_UGID); ensure_user_exists(RESTRICTED_PARENT_UGID); ensure_user_exists(ALLOWED_CHILD1_UGID); ensure_user_exists(ALLOWED_CHILD2_UGID); ensure_user_exists(NO_POLICY_UGID); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/safesetid/safesetid-test.c
static void ensure_groups_exist(void) { ensure_group_exists(ROOT_UGID); ensure_group_exists(RESTRICTED_PARENT_UGID); ensure_group_exists(ALLOWED_CHILD1_UGID); ensure_group_exists(ALLOWED_CHILD2_UGID); ensure_group_exists(NO_POLICY_UGID); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sched/cs_prctl_test.c
static void handle_usage(int rc, char *msg) { puts(USAGE); puts(msg); putchar('\n'); exit(rc); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_benchmark.c
unsigned long long timing(clockid_t clk_id, unsigned long long samples) { struct timespec start, finish; unsigned long long i; pid_t pid, ret; pid = getpid(); assert(clock_gettime(clk_id, &start) == 0); for (i = 0; i < samples; i++) { ret = syscall(__NR_getpid); assert(pid == ret); } assert(cl...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_benchmark.c
bool approx(int i_one, int i_two) { double one = i_one, one_bump = one * 0.01; double two = i_two, two_bump = two * 0.01; one_bump = one + MAX(one_bump, 2.0); two_bump = two + MAX(two_bump, 2.0); if (one == two || (one > two && one <= two_bump) || (two > one && two <= one_bump)) return true; ret...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_bpf.c
static int __filecmp(pid_t pid1, pid_t pid2, int fd1, int fd2) { #ifdef __NR_kcmp errno = 0; return syscall(__NR_kcmp, pid1, pid2, KCMP_FILE, fd1, fd2); #else errno = ENOSYS; return -1; #endif } #define filecmp(pid1, pid2, fd1, fd2) \ ({ ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_bpf.c
void tracer_stop(int sig) { tracer_running = false; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_bpf.c
void cont_handler(int num) {}
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_bpf.c
pid_t setup_trace_fixture(struct __test_metadata *_metadata, tracer_func_t func, void *args, bool ptrace_syscall) { char sync; int pipefd[2]; pid_t tracer_pid; pid_t tracee = getpid(); ASSERT_EQ(0, pipe(pipefd)); /* Fork a child which we'll promote to tracer */ tracer_pid = for...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_bpf.c
void tracer_poke(struct __test_metadata *_metadata, pid_t tracee, int status, void *args) { int ret; unsigned long msg; struct tracer_args_poke_t *info = (struct tracer_args_poke_t *)args; ret = ptrace(PTRACE_GETEVENTMSG, tracee, NULL, &msg); EXPECT_EQ(0, ret); ASSERT_EQ(0x1001, msg) { ki...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/seccomp/seccomp_bpf.c
static ssize_t get_nth(struct __test_metadata *_metadata, const char *path, const unsigned int position, char **entry) { char *line = NULL; unsigned int i; ssize_t nread; size_t len = 0; FILE *f; f = fopen(path, "r"); ASSERT_NE(f, NULL) { TH_LOG("Could not open %s: %s", path, strer...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sgx/load.c
static bool encl_map_bin(const char *path, struct encl *encl) { struct stat sb; void *bin; int ret; int fd; fd = open(path, O_RDONLY); if (fd == -1) { perror("enclave executable open()"); return false; } ret = stat(path, &sb); if (ret) { perror("enclave executable stat()"); goto err...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/load.c
static bool encl_ioc_add_pages(struct encl *encl, struct encl_segment *seg) { struct sgx_enclave_add_pages ioc; struct sgx_secinfo secinfo; int rc; memset(&secinfo, 0, sizeof(secinfo)); secinfo.flags = seg->flags; ioc.src = (uint64_t)seg->src; ioc.offset = seg->offset; ioc.length = seg->size; ioc.s...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sgx/main.c
static Elf64_Dyn *vdso_get_dyntab(void *addr) { Elf64_Ehdr *ehdr = addr; Elf64_Phdr *phdrtab = addr + ehdr->e_phoff; int i; for (i = 0; i < ehdr->e_phnum; i++) if (phdrtab[i].p_type == PT_DYNAMIC) return addr + phdrtab[i].p_offset; return NULL; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/main.c
static void *vdso_get_dyn(void *addr, Elf64_Dyn *dyntab, Elf64_Sxword tag) { int i; for (i = 0; dyntab[i].d_tag != DT_NULL; i++) if (dyntab[i].d_tag == tag) return addr + dyntab[i].d_un.d_ptr; return NULL; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/main.c
static unsigned long sgx_calc_section_metric(unsigned int low, unsigned int high) { return (low & GENMASK_ULL(31, 12)) + ((high & GENMASK_ULL(19, 0)) << 32); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/main.c
static unsigned long get_total_epc_mem(void) { unsigned int eax, ebx, ecx, edx; unsigned long total_size = 0; unsigned int type; int section = 0; while (true) { __cpuid_count(SGX_CPUID, section + SGX_CPUID_EPC, eax, ebx, ecx, edx); type = eax & SGX_CPUID_EPC_MASK; if (type == SGX_CPUID_EPC_INVAL...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sgx/main.c
static int test_handler(long rdi, long rsi, long rdx, long ursp, long r8, long r9, struct sgx_enclave_run *run) { run->user_data = 0; return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/sigstruct.c
static bool alloc_q1q2_ctx(const uint8_t *s, const uint8_t *m, struct q1q2_ctx *ctx) { ctx->bn_ctx = BN_CTX_new(); ctx->s = BN_bin2bn(s, SGX_MODULUS_SIZE, NULL); ctx->m = BN_bin2bn(m, SGX_MODULUS_SIZE, NULL); ctx->q1 = BN_new(); ctx->qr = BN_new(); ctx->q2 = BN_new(); if (!ctx...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/sigstruct.c
static inline const BIGNUM *get_modulus(RSA *key) { const BIGNUM *n; RSA_get0_key(key, &n, NULL, NULL); return n; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/sigstruct.c
static RSA *gen_sign_key(void) { unsigned long sign_key_length; BIO *bio; RSA *key; sign_key_length = (unsigned long)&sign_key_end - (unsigned long)&sign_key; bio = BIO_new_mem_buf(&sign_key, sign_key_length); if (!bio) return NULL; key = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL); BIO_fr...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sgx/sigstruct.c
static bool mrenclave_ecreate(EVP_MD_CTX *ctx, uint64_t blob_size) { struct mrecreate mrecreate; uint64_t encl_size; for (encl_size = 0x1000; encl_size < blob_size;) encl_size <<= 1; memset(&mrecreate, 0, sizeof(mrecreate)); mrecreate.tag = MRECREATE; mrecreate.ssaframesize = 1; mrecreate.size = e...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sgx/test_encl.c
static void do_encl_init_tcs_page(void *_op) { struct encl_op_init_tcs_page *op = _op; void *tcs = (void *)op->tcs_page; uint32_t val_32; memset(tcs, 0, 16); memcpy(tcs + 16, &op->ssa, 8); /* OSSA */ memset(tcs + 24, 0, 4); /* CSSA */ val_32 = 1; memcpy(tcs + 28, &val_32, 4); /* NSSA */ mem...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sgx/test_encl.c
static void do_encl_op_get_from_buf(void *op) { struct encl_op_get_from_buf *op2 = op; memcpy(&op2->value, &encl_buffer[0], 8); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sgx/test_encl.c
static void do_encl_op_nop(void *_op) {}
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sigaltstack/sas.c
void my_usr1(int sig, siginfo_t *si, void *u) { char *aa; int err; stack_t stk; struct stk_data *p; #if __s390x__ register unsigned long sp asm("%15"); #else register unsigned long sp asm("sp"); #endif if (sp < (unsigned long)sstack || sp >= (unsigned long)sstack + stack_size) { ksft_exit_fail_msg("...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sigaltstack/sas.c
void my_usr2(int sig, siginfo_t *si, void *u) { char *aa; struct stk_data *p; ksft_print_msg("[RUN]\tsignal USR2\n"); aa = alloca(1024); /* try to find the data stored by previous sighandler */ p = memmem(aa, 1024, msg, strlen(msg)); if (p) { ksft_test_result_fail("sigaltstack re-used\n"); /* co...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/size/get_size.c
static int print(const char *s) { size_t len = 0; while (s[len] != '\0') len++; return syscall(SYS_write, STDOUT_FILENO, s, len); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sparc64/drivers/adi-test.c
static void debug_print(int level, const char *s, ...) { va_list args; va_start(args, s); if (DEBUG & level) vfprintf(stdout, s, args); va_end(args); } #ifndef min #define min(x, y) ((x) < (y) ? x : y) #endif #define RETURN_FROM_TEST(_ret) \ do { ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sparc64/drivers/adi-test.c
static void print_ustats(const struct stats *const ustats) { DEBUG_PRINT_L1("%s\t%7d\t%7.0f\t%7.0f\n", ustats->name, ustats->count, (float)ustats->total / (float)ustats->count, (float)ustats->bytes / (float)ustats->count); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sparc64/drivers/adi-test.c
static int build_memory_map(void) { char line[256]; FILE *fp; int i; range_count = 0; fp = fopen("/proc/iomem", "r"); if (!fp) { fprintf(stderr, "/proc/iomem: error %d: %s\n", errno, strerror(errno)); return -errno; } while (fgets(line, sizeof(line), fp) != 0) { if (strstr(line, system_ra...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sparc64/drivers/adi-test.c
static int test3_prpw_unaligned_12541bytes(int fd) { unsigned long paddr = ((start_addr[0] + 0xC000) & ~(ADI_BLKSZ - 1)) + 17; unsigned char version[TEST3_VERSION_SZ], expected_version[TEST3_VERSION_SZ]; loff_t offset; int ret, i; for (i = 0; i < TEST3_VERSION_SZ; i++) { version[i] = random_version(); ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/splice/default_file_splice_read.c
int main(int argc, char **argv) { splice(0, 0, 1, 0, 1 << 30, 0); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sync/sync.c
int sync_wait(int fd, int timeout) { struct pollfd fds; fds.fd = fd; fds.events = POLLIN | POLLERR; return poll(&fds, 1, timeout); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sync/sync.c
int sync_fence_count_with_status(int fd, int status) { unsigned int i, count = 0; struct sync_fence_info *fence_info = NULL; struct sync_file_info *info = sync_file_info(fd); if (!info) return -1; fence_info = (struct sync_fence_info *)(unsigned long)info->sync_fence_info; for (i = 0; i < info->num_f...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sync/sync.c
int sw_sync_fence_create(int fd, const char *name, unsigned int value) { struct sw_sync_create_fence_data data = {}; int err; data.value = value; strncpy(data.name, name, sizeof(data.name) - 1); data.name[sizeof(data.name) - 1] = '\0'; err = ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data); if (err < 0) ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/sync/sync.c
void sw_sync_fence_destroy(int fd) { if (sw_sync_fence_is_valid(fd)) close(fd); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/sync/sync_merge.c
int test_fence_merge_same_fence(void) { int fence, valid, merged; int timeline = sw_sync_timeline_create(); valid = sw_sync_timeline_is_valid(timeline); ASSERT(valid, "Failure allocating timeline\n"); fence = sw_sync_fence_create(timeline, "allocFence", 5); valid = sw_sync_fence_is_valid(fence); ASSERT...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
static double one_sysinfo_step(void) { struct timespec t1, t2; int i; struct sysinfo info; clock_gettime(CLOCK_MONOTONIC, &t1); for (i = 0; i < CALIBRATION_STEP; i++) sysinfo(&info); clock_gettime(CLOCK_MONOTONIC, &t2); return (t2.tv_sec - t1.tv_sec) + 1.0e-9 * (t2.tv_nsec - t1.tv_nsec); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/syscall_user_dispatch/sud_benchmark.c
static void handle_sigsys(int sig, siginfo_t *info, void *ucontext) { char buf[1024]; int len; SYSCALL_UNBLOCK; len = snprintf(buf, 1024, "Caught sys_%x\n", info->si_syscall); write(1, buf, len); if (info->si_syscall == MAGIC_SYSCALL_1) trapped_call_count++; else native_call_count++; #ifdef TE...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/tc-testing/action.c
int action_ko(struct __sk_buff *s) { s->data = 0x0; return TC_ACT_OK; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timens/clock_nanosleep.c
void *call_nanosleep(void *_args) { struct thread_args *args = _args; clock_nanosleep(args->clockid, args->abs ? TIMER_ABSTIME : 0, args->now, args->rem); pthread_mutex_unlock(args->lock); return NULL; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timens/futex.c
static int run_test(int clockid) { int futex_op = FUTEX_WAIT_BITSET; struct timespec timeout, end; int val = 0; if (clockid == CLOCK_REALTIME) futex_op |= FUTEX_CLOCK_REALTIME; clock_gettime(clockid, &timeout); timeout.tv_nsec += NSEC_PER_SEC / 10; if (timeout.tv_nsec > NSEC_PER_SEC) { timeout.t...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timens/gettime_perf.c
static void test(clock_t clockid, char *clockstr, bool in_ns) { struct timespec tp, start; long i = 0; const int timeout = 3; vdso_clock_gettime(clockid, &start); tp = start; for (tp = start; start.tv_sec + timeout > tp.tv_sec || (start.tv_sec + timeout == tp.tv_sec && start.tv_nsec > tp.tv_...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timens/procfs.c
static int switch_ns(int fd) { if (setns(fd, CLONE_NEWTIME)) return pr_perror("setns()"); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timens/procfs.c
static int read_proc_uptime(struct timespec *uptime) { unsigned long up_sec, up_nsec; FILE *proc; proc = fopen("/proc/uptime", "r"); if (proc == NULL) { pr_perror("Unable to open /proc/uptime"); return -1; } if (fscanf(proc, "%lu.%02lu", &up_sec, &up_nsec) != 2) { if (errno) { pr_perror...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timens/procfs.c
static int check_uptime(void) { struct timespec uptime_new, uptime_old; time_t uptime_expected; double prec = MAX_TEST_TIME_SEC; if (switch_ns(parent_ns)) return pr_err("switch_ns(%d)", parent_ns); if (read_proc_uptime(&uptime_old)) return 1; if (switch_ns(child_ns)) return pr_err("switch_ns...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timens/timens.h
static inline int _settime(clockid_t clk_id, time_t offset) { int fd, len; char buf[4096]; if (clk_id == CLOCK_MONOTONIC_COARSE || clk_id == CLOCK_MONOTONIC_RAW) clk_id = CLOCK_MONOTONIC; len = snprintf(buf, sizeof(buf), "%d %ld 0", clk_id, offset); fd = open("/proc/self/timens_offsets", O_WRONLY); ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timens/timens.h
static inline void nscheck(void) { if (access("/proc/self/ns/time", F_OK) < 0) ksft_exit_skip("Time namespaces are not supported\n"); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timens/timerfd.c
int run_test(int clockid, struct timespec now) { struct itimerspec new_value; long long elapsed; int fd, i; if (check_skip(clockid)) return 0; if (tclock_gettime(clockid, &now)) return pr_perror("clock_gettime(%d)", clockid); for (i = 0; i < 2; i++) { int flags = 0; new_value.it_value.t...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timens/vfork_exec.c
static int check_in_thread(char *tst_name, struct timespec *now) { struct thread_args args = { .tst_name = tst_name, .now = now, }; pthread_t th; void *retval; if (pthread_create(&th, NULL, tcheck, &args)) return pr_perror("thread"); if (pthread_join(th, &retval)) return pr_perror("pth...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/adjtick.c
long long llabs(long long val) { if (val < 0) val = -val; return val; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/adjtick.c
int main(int argc, char **argv) { struct timespec raw; long tick, max, interval, err; struct timex tx1; err = 0; setbuf(stdout, NULL); if (clock_gettime(CLOCK_MONOTONIC_RAW, &raw)) { printf("ERR: NO CLOCK_MONOTONIC_RAW\n"); return -1; } printf("Each iteration takes about 15 seconds\n"); sy...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/alarmtimer-suspend.c
char *clockstring(int clockid) { switch (clockid) { case CLOCK_REALTIME: return "CLOCK_REALTIME"; case CLOCK_MONOTONIC: return "CLOCK_MONOTONIC"; case CLOCK_PROCESS_CPUTIME_ID: return "CLOCK_PROCESS_CPUTIME_ID"; case CLOCK_THREAD_CPUTIME_ID: return "CLOCK_THREAD_CPUTIME_ID"; case CLOCK_MON...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/clocksource-switch.c
int change_clocksource(char *clocksource) { int fd; ssize_t size; fd = open("/sys/devices/system/clocksource/clocksource0/current_clocksource", O_WRONLY); if (fd < 0) return -1; size = write(fd, clocksource, strlen(clocksource)); if (size < 0) return -1; close(fd); return 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/clocksource-switch.c
int main(int argc, char **argv) { char orig_clk[512]; int count, i, status, opt; int do_sanity_check = 1; int runtime = 60; pid_t pid; while ((opt = getopt(argc, argv, "st:")) != -1) { switch (opt) { case 's': do_sanity_check = 0; break; case 't': runtime = atoi(optarg); ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/freq-step.c
static void set_frequency(double freq) { struct timex txc; int tick_offset; tick_offset = 1e6 * freq / user_hz; txc.modes = ADJ_TICK | ADJ_FREQUENCY; txc.tick = 1000000 / user_hz + tick_offset; txc.freq = (1e6 * freq - user_hz * tick_offset) * (1 << 16); if (adjtimex(&txc) < 0) { perror("[FAIL] ad...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/freq-step.c
int main(int argc, char **argv) { double freq_base, freq_step; int i, j, fails = 0; init_test(); printf("Checking response to frequency step:\n"); printf(" Step 1st interval 2nd interval\n"); printf(" Freq Dev Max Freq Dev Max\n"); for (i = 2; i ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/inconsistency-check.c
int main(int argc, char *argv[]) { int clockid, opt; int userclock = CLOCK_REALTIME; int maxclocks = NR_CLOCKIDS; int runtime = 10; struct timespec ts; while ((opt = getopt(argc, argv, "t:c:")) != -1) { switch (opt) { case 't': runtime = atoi(optarg); break; case 'c': usercloc...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/leap-a-day.c
void handler(int unused) { clear_time_state(); exit(0); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/leap-a-day.c
void test_hrtimer_failure(void) { struct timespec now, target; clock_gettime(CLOCK_REALTIME, &now); target = timespec_add(now, NSEC_PER_SEC / 2); clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &target, NULL); clock_gettime(CLOCK_REALTIME, &now); if (!in_order(target, now)) { printf("ERROR: hrtimer ear...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/nanosleep.c
char *clockstring(int clockid) { switch (clockid) { case CLOCK_REALTIME: return "CLOCK_REALTIME"; case CLOCK_MONOTONIC: return "CLOCK_MONOTONIC"; case CLOCK_PROCESS_CPUTIME_ID: return "CLOCK_PROCESS_CPUTIME_ID"; case CLOCK_THREAD_CPUTIME_ID: return "CLOCK_THREAD_CPUTIME_ID"; case CLOCK_MONO...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/nanosleep.c
struct timespec timespec_add(struct timespec ts, unsigned long long ns) { ts.tv_nsec += ns; while (ts.tv_nsec >= NSEC_PER_SEC) { ts.tv_nsec -= NSEC_PER_SEC; ts.tv_sec++; } return ts; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/nanosleep.c
int nanosleep_test(int clockid, long long ns) { struct timespec now, target, rel; if (clock_gettime(clockid, &now)) return UNSUPPORTED; target = timespec_add(now, ns); if (clock_nanosleep(clockid, TIMER_ABSTIME, &target, NULL)) return UNSUPPORTED; clock_gettime(clockid, &now); if (!in_order(targe...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/nsleep-lat.c
int nanosleep_lat_test(int clockid, long long ns) { struct timespec start, end, target; long long latency = 0; int i, count; target.tv_sec = ns / NSEC_PER_SEC; target.tv_nsec = ns % NSEC_PER_SEC; if (clock_gettime(clockid, &start)) return UNSUPPORTED; if (clock_nanosleep(clockid, 0, &target, NULL)) ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/posix_timers.c
static int check_diff(struct timeval start, struct timeval end) { long long diff; diff = end.tv_usec - start.tv_usec; diff += (end.tv_sec - start.tv_sec) * USECS_PER_SEC; if (abs(diff - DELAY * USECS_PER_SEC) > USECS_PER_SEC / 2) { printf("Diff too high: %lld..", diff); return -1; } return 0; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/raw_skew.c
struct timespec nsec_to_ts(long long ns) { struct timespec ts; ts.tv_sec = ns / NSEC_PER_SEC; ts.tv_nsec = ns % NSEC_PER_SEC; return ts; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/raw_skew.c
void get_monotonic_and_raw(struct timespec *mon, struct timespec *raw) { struct timespec start, mid, end; long long diff = 0, tmp; int i; for (i = 0; i < 3; i++) { long long newdiff; clock_gettime(CLOCK_MONOTONIC, &start); clock_gettime(CLOCK_MONOTONIC_RAW, &mid); clock_gettime(CLOCK_MONOTONI...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-2038.c
int is32bits(void) { return (sizeof(long) == 4); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-2038.c
int main(int argc, char *argv[]) { int ret = 0; int opt, dangerous = 0; time_t start; while ((opt = getopt(argc, argv, "d")) != -1) { switch (opt) { case 'd': dangerous = 1; } } start = time(0); /* First test that crazy values don't work */ if (!settime(YEAR_1901)) { ret = -1; ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-tai.c
int get_tai(void) { struct timex tx; memset(&tx, 0, sizeof(tx)); adjtimex(&tx); return tx.tai; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-tai.c
int main(int argc, char **argv) { int i, ret; ret = get_tai(); printf("tai offset started at %i\n", ret); printf("Checking tai offsets can be properly set: "); fflush(stdout); for (i = 1; i <= 60; i++) { ret = set_tai(i); ret = get_tai(); if (ret != i) { printf("[FAILED] expected: %i go...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-timer-lat.c
long long timespec_sub(struct timespec a, struct timespec b) { long long ret = NSEC_PER_SEC * b.tv_sec + b.tv_nsec; ret -= NSEC_PER_SEC * a.tv_sec + a.tv_nsec; return ret; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-timer-lat.c
void describe_timer(int flags, int interval) { printf("%-22s %s %s ", clockstring(clock_id), flags ? "ABSTIME" : "RELTIME", interval ? "PERIODIC" : "ONE-SHOT"); }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-timer-lat.c
int setup_timer(int clock_id, int flags, int interval, timer_t *tm1) { struct sigevent se; struct itimerspec its1, its2; int err; memset(&se, 0, sizeof(se)); se.sigev_notify = SIGEV_SIGNAL; se.sigev_signo = SIGRTMAX; se.sigev_value.sival_int = 0; max_latency_ns = 0; alarmcount = 0; timer_fired_ear...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-timer-lat.c
int check_alarmcount(int flags, int interval) { describe_timer(flags, interval); printf("count: %19d : ", alarmcount); if (alarmcount == 1) { printf("[OK]\n"); return 0; } printf("[FAILED]\n"); return -1; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-timer-lat.c
int main(void) { struct sigaction act; int signum = SIGRTMAX; int ret = 0; sigfillset(&act.sa_mask); act.sa_flags = 0; act.sa_handler = sigalarm; sigaction(signum, &act, NULL); printf("Setting timers for every %i seconds\n", TIMER_SECS); for (clock_id = 0; clock_id < NR_CLOCKIDS; clock_id++) { ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/set-tz.c
int get_tz_dst(void) { struct timezone tz; struct timeval tv; memset(&tz, 0, sizeof(tz)); gettimeofday(&tv, &tz); return tz.tz_dsttime; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/timers/valid-adjtimex.c
int clear_time_state(void) { struct timex tx; int ret; tx.modes = ADJ_STATUS; tx.status = 0; ret = adjtimex(&tx); return ret; } #define NUM_FREQ_VALID 32 #define NUM_FREQ_OUTOFRANGE 4 #define NUM_FREQ_INVALID 2
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/timers/valid-adjtimex.c
int main(int argc, char **argv) { if (validate_freq()) return ksft_exit_fail(); if (validate_set_offset()) return ksft_exit_fail(); return ksft_exit_pass(); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/uevent/uevent_filtering.c
static void signal_handler(int sig) { if (sig == SIGTERM) _exit(EXIT_SUCCESS); _exit(EXIT_FAILURE); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/user_events/dyn_test.c
int main(int argc, char **argv) { return test_harness_run(argc, argv); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/user_events/ftrace_test.c
int main(int argc, char **argv) { return test_harness_run(argc, argv); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/user_events/perf_test.c
static int get_id(void) { FILE *fp = fopen(id_file, "r"); int ret, id = 0; if (!fp) return -1; ret = fscanf(fp, "%d", &id); fclose(fp); if (ret != 1) return -1; return id; }
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/user_events/perf_test.c
int main(int argc, char **argv) { return test_harness_run(argc, argv); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/parse_vdso.c
void *vdso_sym(const char *version, const char *name) { unsigned long ver_hash; if (!vdso_info.valid) return 0; ver_hash = elf_hash(version); ELF(Word) chain = vdso_info.bucket[elf_hash(name) % vdso_info.nbucket]; for (; chain != STN_UNDEF; chain = vdso_info.chain[chain]) { ELF(Sym) *sym = &vdso_inf...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_abi.c
static void vdso_test_clock_gettime(clockid_t clk_id) { vdso_clock_gettime_t vdso_clock_gettime = (vdso_clock_gettime_t)vdso_sym(version, name[1]); if (!vdso_clock_gettime) { ksft_test_result_skip(VDSO_TEST_SKIP_MSG(name[1])); return; } struct timespec ts; long ret = vdso_clock_gettime(clk_id...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_abi.c
static void vdso_test_time(void) { vdso_time_t vdso_time = (vdso_time_t)vdso_sym(version, name[2]); if (!vdso_time) { ksft_test_result_skip(VDSO_TEST_SKIP_MSG(name[2])); return; } long ret = vdso_time(NULL); if (ret > 0) { ksft_print_msg("The time in hours since January 1, 1970 is %lld\n", ...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_clock_getres.c
int main(int argc, char **argv) { int ret; #if _POSIX_TIMERS > 0 #ifdef CLOCK_REALTIME ret = vdso_test_clock(CLOCK_REALTIME); #endif #ifdef CLOCK_BOOTTIME ret += vdso_test_clock(CLOCK_BOOTTIME); #endif #ifdef CLOCK_TAI ret += vdso_test_clock(CLOCK_TAI); #endif #ifdef CLOCK_REALTIME_COARSE ret += vdso_te...
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
static long sys_getcpu(unsigned *cpu, unsigned *node, void *cache) { return syscall(__NR_getcpu, cpu, node, cache); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
static inline int sys_gettimeofday(struct timeval *tv, struct timezone *tz) { return syscall(__NR_gettimeofday, tv, tz); }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
static void test_getcpu(void) { printf("[RUN]\tTesting getcpu...\n"); for (int cpu = 0;; cpu++) { cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(cpu, &cpuset); if (sched_setaffinity(0, sizeof(cpuset), &cpuset) != 0) return; unsigned cpu_sys, cpu_vdso, cpu_vsys, node_sys, node_vdso, node_v...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
static bool ts64_leq(const struct __kernel_timespec *a, const struct __kernel_timespec *b) { if (a->tv_sec != b->tv_sec) return a->tv_sec < b->tv_sec; else return a->tv_nsec <= b->tv_nsec; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
static bool tv_leq(const struct timeval *a, const struct timeval *b) { if (a->tv_sec != b->tv_sec) return a->tv_sec < b->tv_sec; else return a->tv_usec <= b->tv_usec; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
static void test_one_clock_gettime64(int clock, const char *name) { struct __kernel_timespec start, vdso, end; int vdso_ret, end_ret; printf("[RUN]\tTesting clock_gettime64 for clock %s (%d)...\n", name, clock); if (sys_clock_gettime64(clock, &start) < 0) { if (errno == EINVAL) { vdso_ret = vdso_cl...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_correctness.c
int main(int argc, char **argv) { name = (const char **)&names[VDSO_NAMES]; fill_function_pointers(); test_clock_gettime(); test_clock_gettime64(); test_gettimeofday(); test_getcpu(); return nerrs ? 1 : 0; }
[ 0, 0 ]
Linux Kernel
tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
int main(int argc, char **argv) { unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); if (!sysinfo_ehdr) { printf("AT_SYSINFO_EHDR is not present!\n"); return KSFT_SKIP; } vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); ...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/vm/compaction_test.c
int read_memory_info(unsigned long *memfree, unsigned long *hugepagesize) { char buffer[256] = {0}; char *cmd = "cat /proc/meminfo | grep -i memfree | grep -o '[0-9]*'"; FILE *cmdfile = popen(cmd, "r"); if (!(fgets(buffer, sizeof(buffer), cmdfile))) { perror("Failed to read meminfo\n"); return -1; }...
[ 1, 0 ]
Linux Kernel
tools/testing/selftests/vm/compaction_test.c
int prereq(void) { char allowed; int fd; fd = open("/proc/sys/vm/compact_unevictable_allowed", O_RDONLY | O_NONBLOCK); if (fd < 0) { perror("Failed to open\n" "/proc/sys/vm/compact_unevictable_allowed\n"); return -1; } if (read(fd, &allowed, sizeof(char)) != sizeof(char)) { perror(...
[ 1, 0 ]