Skip to content
Snippets Groups Projects
Select Git revision
  • 811d7e375d08312dba23f3b6bf7e58ec14aa5dcb
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

test_progs.c

Blame
  • test_progs.c 15.52 KiB
    // SPDX-License-Identifier: GPL-2.0-only
    /* Copyright (c) 2017 Facebook
     */
    #define _GNU_SOURCE
    #include "test_progs.h"
    #include "cgroup_helpers.h"
    #include "bpf_rlimit.h"
    #include <argp.h>
    #include <pthread.h>
    #include <sched.h>
    #include <signal.h>
    #include <string.h>
    #include <execinfo.h> /* backtrace */
    
    /* defined in test_progs.h */
    struct test_env env = {};
    
    struct prog_test_def {
    	const char *test_name;
    	int test_num;
    	void (*run_test)(void);
    	bool force_log;
    	int error_cnt;
    	int skip_cnt;
    	bool tested;
    	bool need_cgroup_cleanup;
    
    	char *subtest_name;
    	int subtest_num;
    
    	/* store counts before subtest started */
    	int old_error_cnt;
    };
    
    /* Override C runtime library's usleep() implementation to ensure nanosleep()
     * is always called. Usleep is frequently used in selftests as a way to
     * trigger kprobe and tracepoints.
     */
    int usleep(useconds_t usec)
    {
    	struct timespec ts = {
    		.tv_sec = usec / 1000000,
    		.tv_nsec = (usec % 1000000) * 1000,
    	};
    
    	return syscall(__NR_nanosleep, &ts, NULL);
    }
    
    static bool should_run(struct test_selector *sel, int num, const char *name)
    {
    	int i;
    
    	for (i = 0; i < sel->blacklist.cnt; i++) {
    		if (strstr(name, sel->blacklist.strs[i]))
    			return false;
    	}
    
    	for (i = 0; i < sel->whitelist.cnt; i++) {
    		if (strstr(name, sel->whitelist.strs[i]))
    			return true;
    	}
    
    	if (!sel->whitelist.cnt && !sel->num_set)
    		return true;
    
    	return num < sel->num_set_len && sel->num_set[num];
    }
    
    static void dump_test_log(const struct prog_test_def *test, bool failed)
    {