Commit 1caaf0a6 authored by Daniel Vetter's avatar Daniel Vetter
parent 814b1355
......@@ -277,7 +277,7 @@ int drm_open_any(void)
return fd;
gem_quiescent_gpu(fd);
drmtest_install_exit_handler(quiescent_gpu_at_exit);
igt_install_exit_handler(quiescent_gpu_at_exit);
return fd;
}
......@@ -406,9 +406,9 @@ void gem_check_caching(int fd)
gem_close(fd, arg.handle);
if (ret != 0) {
if (!drmtest_only_list_subtests())
if (!igt_only_list_subtests())
printf("no set_caching support detected\n");
drmtest_skip();
igt_skip();
}
}
......@@ -422,7 +422,7 @@ void gem_set_caching(int fd, uint32_t handle, int caching)
ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
if (ret != 0 && (errno == ENOTTY || errno == EINVAL))
drmtest_skip();
igt_skip();
else
assert(ret == 0);
}
......@@ -635,15 +635,15 @@ static void sig_handler(int i)
static void signal_helper_exit_handler(int sig)
{
drmtest_stop_signal_helper();
igt_stop_signal_helper();
}
void drmtest_fork_signal_helper(void)
void igt_fork_signal_helper(void)
{
pid_t pid;
sighandler_t oldsig;
drmtest_install_exit_handler(signal_helper_exit_handler);
igt_install_exit_handler(signal_helper_exit_handler);
signal(SIGUSR1, sig_handler);
oldsig = signal(SIGQUIT, SIG_DFL);
......@@ -657,7 +657,7 @@ void drmtest_fork_signal_helper(void)
signal_helper = pid;
}
void drmtest_stop_signal_helper(void)
void igt_stop_signal_helper(void)
{
int exitcode;
......@@ -680,7 +680,7 @@ static bool in_subtest = false;
static bool test_with_subtests = false;
static bool skip_subtests_henceforth = false;
void drmtest_subtest_init(int argc, char **argv)
void igt_subtest_init(int argc, char **argv)
{
int c, option_index = 0;
static struct option long_options[] = {
......@@ -714,10 +714,10 @@ out:
/*
* Note: Testcases which use these helpers MUST NOT output anything to stdout
* outside of places protected by drmtest_run_subtest checks - the piglit
* outside of places protected by igt_run_subtest checks - the piglit
* runner adds every line to the subtest list.
*/
bool __drmtest_run_subtest(const char *subtest_name)
bool __igt_run_subtest(const char *subtest_name)
{
assert(in_subtest == false);
......@@ -739,7 +739,7 @@ bool __drmtest_run_subtest(const char *subtest_name)
}
}
bool drmtest_only_list_subtests(void)
bool igt_only_list_subtests(void)
{
return list_subtests;
}
......@@ -747,16 +747,16 @@ bool drmtest_only_list_subtests(void)
static bool skipped_one = false;
static bool succeeded_one = false;
static bool failed_one = false;
static int drmtest_exitcode;
static int igt_exitcode;
static void exit_subtest(void) __attribute__((noreturn));
static void exit_subtest(void)
{
in_subtest = false;
longjmp(drmtest_subtest_jmpbuf, 1);
longjmp(igt_subtest_jmpbuf, 1);
}
void drmtest_skip(void)
void igt_skip(void)
{
skipped_one = true;
if (in_subtest)
......@@ -767,19 +767,19 @@ void drmtest_skip(void)
exit(77);
}
void drmtest_success(void)
void igt_success(void)
{
succeeded_one = true;
if (in_subtest)
exit_subtest();
}
void drmtest_fail(int exitcode)
void igt_fail(int exitcode)
{
assert(exitcode != 0 && exitcode != 77);
if (!failed_one)
drmtest_exitcode = exitcode;
igt_exitcode = exitcode;
failed_one = true;
......@@ -791,16 +791,16 @@ void drmtest_fail(int exitcode)
}
}
int drmtest_retval(void)
int igt_retval(void)
{
if (drmtest_only_list_subtests())
if (igt_only_list_subtests())
return 0;
/* Calling this without calling one of the above is a failure */
assert(skipped_one || succeeded_one || failed_one);
if (failed_one)
return drmtest_exitcode;
return igt_exitcode;
else if (succeeded_one)
return 0;
else
......@@ -818,7 +818,7 @@ static bool env_set(const char *env_var, bool default_value)
return atoi(val) != 0;
}
bool drmtest_run_in_simulation(void)
bool igt_run_in_simulation(void)
{
static int simulation = -1;
......@@ -830,17 +830,17 @@ bool drmtest_run_in_simulation(void)
/* Skip the test when running on simulation (and that's relevant only when
* we're not in the mode where we list the subtests) */
void drmtest_skip_on_simulation(void)
void igt_skip_on_simulation(void)
{
if (drmtest_only_list_subtests())
if (igt_only_list_subtests())
return;
if (drmtest_run_in_simulation())
if (igt_run_in_simulation())
exit(77);
}
/* other helpers */
void drmtest_exchange_int(void *array, unsigned i, unsigned j)
void igt_exchange_int(void *array, unsigned i, unsigned j)
{
int *int_arr, tmp;
int_arr = array;
......@@ -850,7 +850,7 @@ void drmtest_exchange_int(void *array, unsigned i, unsigned j)
int_arr[j] = tmp;
}
void drmtest_permute_array(void *array, unsigned size,
void igt_permute_array(void *array, unsigned size,
void (*exchange_func)(void *array,
unsigned i,
unsigned j))
......@@ -865,7 +865,7 @@ void drmtest_permute_array(void *array, unsigned size,
}
}
void drmtest_progress(const char *header, uint64_t i, uint64_t total)
void igt_progress(const char *header, uint64_t i, uint64_t total)
{
int divider = 200;
......@@ -891,7 +891,7 @@ void drmtest_progress(const char *header, uint64_t i, uint64_t total)
drm_intel_bo **trash_bos;
int num_trash_bos;
void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
{
int i;
......@@ -904,7 +904,7 @@ void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
}
void drmtest_trash_aperture(void)
void igt_trash_aperture(void)
{
int i;
uint8_t *gtt_ptr;
......@@ -917,7 +917,7 @@ void drmtest_trash_aperture(void)
}
}
void drmtest_cleanup_aperture_trashers(void)
void igt_cleanup_aperture_trashers(void)
{
int i;
......@@ -1397,7 +1397,7 @@ static struct {
bool installed;
} orig_sig[MAX_SIGNALS];
static drmtest_exit_handler_t exit_handler_fn[MAX_EXIT_HANDLERS];
static igt_exit_handler_t exit_handler_fn[MAX_EXIT_HANDLERS];
static int exit_handler_count;
static bool exit_handler_disabled;
static sigset_t saved_sig_mask;
......@@ -1443,7 +1443,7 @@ static void call_exit_handlers(int sig)
exit_handler_fn[i](sig);
}
static void drmtest_atexit_handler(void)
static void igt_atexit_handler(void)
{
restore_all_sig_handler();
......@@ -1451,7 +1451,7 @@ static void drmtest_atexit_handler(void)
call_exit_handlers(0);
}
static void drmtest_sig_handler(int sig)
static void igt_sig_handler(int sig)
{
restore_all_sig_handler();
......@@ -1475,7 +1475,7 @@ static void drmtest_sig_handler(int sig)
* The handler will be passed the signal number if called due to a signal, or
* 0 otherwise.
*/
int drmtest_install_exit_handler(drmtest_exit_handler_t fn)
int igt_install_exit_handler(igt_exit_handler_t fn)
{
int i;
......@@ -1490,11 +1490,11 @@ int drmtest_install_exit_handler(drmtest_exit_handler_t fn)
for (i = 0; i < ARRAY_SIZE(handled_signals); i++) {
if (install_sig_handler(handled_signals[i],
drmtest_sig_handler))
igt_sig_handler))
goto err;
}
if (atexit(drmtest_atexit_handler))
if (atexit(igt_atexit_handler))
goto err;
return 0;
......@@ -1505,7 +1505,7 @@ err:
return -1;
}
void drmtest_disable_exit_handler(void)
void igt_disable_exit_handler(void)
{
sigset_t set;
int i;
......@@ -1525,7 +1525,7 @@ void drmtest_disable_exit_handler(void)
exit_handler_disabled = true;
}
void drmtest_enable_exit_handler(void)
void igt_enable_exit_handler(void)
{
if (!exit_handler_disabled)
return;
......@@ -1575,16 +1575,16 @@ static void restore_vt_mode_at_exit(int sig)
* original mode.
*/
int drmtest_set_vt_graphics_mode(void)
int igt_set_vt_graphics_mode(void)
{
if (drmtest_install_exit_handler(restore_vt_mode_at_exit))
if (igt_install_exit_handler(restore_vt_mode_at_exit))
return -1;
drmtest_disable_exit_handler();
igt_disable_exit_handler();
orig_vt_mode = set_vt_mode(KD_GRAPHICS);
if (orig_vt_mode < 0)
orig_vt_mode = -1UL;
drmtest_enable_exit_handler();
igt_enable_exit_handler();
return orig_vt_mode < 0 ? -1 : 0;
}
......@@ -1725,7 +1725,7 @@ void kmstest_free_connector_config(struct kmstest_connector_config *config)
}
#define PREFAULT_DEBUGFS "/sys/module/i915/parameters/prefault_disable"
static int drmtest_prefault_control(bool enable)
static int igt_prefault_control(bool enable)
{
const char *name = PREFAULT_DEBUGFS;
int fd;
......@@ -1758,22 +1758,22 @@ static int drmtest_prefault_control(bool enable)
static void enable_prefault_at_exit(int sig)
{
drmtest_enable_prefault();
igt_enable_prefault();
}
int drmtest_disable_prefault(void)
int igt_disable_prefault(void)
{
drmtest_install_exit_handler(enable_prefault_at_exit);
igt_install_exit_handler(enable_prefault_at_exit);
return drmtest_prefault_control(false);
return igt_prefault_control(false);
}
int drmtest_enable_prefault(void)
int igt_enable_prefault(void)
{
return drmtest_prefault_control(true);
return igt_prefault_control(true);
}
void drmtest_system_suspend_autoresume(void)
void igt_system_suspend_autoresume(void)
{
int ret;
......
......@@ -86,36 +86,36 @@ int prime_handle_to_fd(int fd, uint32_t handle);
uint32_t prime_fd_to_handle(int fd, int dma_buf_fd);
/* generally useful helpers */
void drmtest_fork_signal_helper(void);
void drmtest_stop_signal_helper(void);
void drmtest_exchange_int(void *array, unsigned i, unsigned j);
void drmtest_permute_array(void *array, unsigned size,
void igt_fork_signal_helper(void);
void igt_stop_signal_helper(void);
void igt_exchange_int(void *array, unsigned i, unsigned j);
void igt_permute_array(void *array, unsigned size,
void (*exchange_func)(void *array,
unsigned i,
unsigned j));
void drmtest_progress(const char *header, uint64_t i, uint64_t total);
void igt_progress(const char *header, uint64_t i, uint64_t total);
/* subtest infrastructure */
jmp_buf drmtest_subtest_jmpbuf;
void drmtest_subtest_init(int argc, char **argv);
bool __drmtest_run_subtest(const char *subtest_name);
#define drmtest_subtest(name) for (; __drmtest_run_subtest((name)) && \
(setjmp(drmtest_subtest_jmpbuf) == 0); \
drmtest_success())
bool drmtest_only_list_subtests(void);
void drmtest_skip(void);
void drmtest_success(void);
void drmtest_fail(int exitcode) __attribute__((noreturn));
int drmtest_retval(void);
/* check functions which auto-skip tests by calling drmtest_skip() */
jmp_buf igt_subtest_jmpbuf;
void igt_subtest_init(int argc, char **argv);
bool __igt_run_subtest(const char *subtest_name);
#define igt_subtest(name) for (; __igt_run_subtest((name)) && \
(setjmp(igt_subtest_jmpbuf) == 0); \
igt_success())
bool igt_only_list_subtests(void);
void igt_skip(void);
void igt_success(void);
void igt_fail(int exitcode) __attribute__((noreturn));
int igt_retval(void);
/* check functions which auto-skip tests by calling igt_skip() */
void gem_check_caching(int fd);
static inline bool gem_check_vebox(int fd)
{
if (gem_has_vebox(fd))
return true;
drmtest_skip();
igt_skip();
return false;
}
......@@ -124,7 +124,7 @@ static inline bool gem_check_bsd(int fd)
if (HAS_BSD_RING(intel_get_drm_devid(fd)))
return true;
drmtest_skip();
igt_skip();
return false;
}
......@@ -133,19 +133,19 @@ static inline bool gem_check_blt(int fd)
if (HAS_BLT_RING(intel_get_drm_devid(fd)))
return true;
drmtest_skip();
igt_skip();
return false;
}
/* helpers to automatically reduce test runtime in simulation */
bool drmtest_run_in_simulation(void);
#define SLOW_QUICK(slow,quick) (drmtest_run_in_simulation() ? (quick) : (slow))
void drmtest_skip_on_simulation(void);
bool igt_run_in_simulation(void);
#define SLOW_QUICK(slow,quick) (igt_run_in_simulation() ? (quick) : (slow))
void igt_skip_on_simulation(void);
/* helpers based upon the libdrm buffer manager */
void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
void drmtest_trash_aperture(void);
void drmtest_cleanup_aperture_trashers(void);
void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
void igt_trash_aperture(void);
void igt_cleanup_aperture_trashers(void);
struct kmstest_connector_config {
drmModeCrtc *crtc;
......@@ -220,19 +220,19 @@ inline static void _do_or_die(const char *function, int line, int ret)
#define do_or_die(x) _do_or_die(__FUNCTION__, __LINE__, x)
#define do_ioctl(fd, ptr, sz) do_or_die(drmIoctl((fd), (ptr), (sz)))
typedef void (*drmtest_exit_handler_t)(int sig);
typedef void (*igt_exit_handler_t)(int sig);
/* reliable atexit helpers, also work when killed by a signal (if possible) */
int drmtest_install_exit_handler(drmtest_exit_handler_t fn);
void drmtest_enable_exit_handler(void);
void drmtest_disable_exit_handler(void);
int igt_install_exit_handler(igt_exit_handler_t fn);
void igt_enable_exit_handler(void);
void igt_disable_exit_handler(void);
/* set vt into graphics mode, required to prevent fbcon from interfering */
int drmtest_set_vt_graphics_mode(void);
int igt_set_vt_graphics_mode(void);
/* prefault disabling, needs the corresponding debugfs interface */
int drmtest_disable_prefault(void);
int drmtest_enable_prefault(void);
int igt_disable_prefault(void);
int igt_enable_prefault(void);
/* suspend and auto-resume system */
void drmtest_system_suspend_autoresume(void);
void igt_system_suspend_autoresume(void);
......@@ -60,7 +60,7 @@ int main(int argc, char **argv)
int i;
char *ptr;
drmtest_skip_on_simulation();
igt_skip_on_simulation();
fd = drm_open_any();
......
......@@ -61,7 +61,7 @@ int main(int argc, char **argv)
char *ptr;
drm_intel_bo *load_bo;
drmtest_skip_on_simulation();
igt_skip_on_simulation();
fd = drm_open_any();
......
......@@ -61,7 +61,7 @@ int main(int argc, char **argv)
int i;
char *ptr;
drmtest_skip_on_simulation();
igt_skip_on_simulation();
fd = drm_open_any();
......
......@@ -62,7 +62,7 @@ int main(int argc, char **argv)
int i;
char *ptr;
drmtest_skip_on_simulation();
igt_skip_on_simulation();
fd = drm_open_any();
......
......@@ -122,7 +122,7 @@ int main(int argc, char **argv)
{
int fd;
drmtest_skip_on_simulation();
igt_skip_on_simulation();
fd = drm_open_any();
......
......@@ -80,15 +80,15 @@ int main(int argc, char **argv)
{
int fd;
drmtest_subtest_init(argc, argv);
igt_subtest_init(argc, argv);
fd = drm_open_any();
drmtest_subtest("bad-close")
igt_subtest("bad-close")
test_bad_close(fd);
drmtest_subtest("create-close")
igt_subtest("create-close")
test_create_close(fd);
drmtest_subtest("create-fd-close")
igt_subtest("create-fd-close")
test_create_fd_close(fd);
return 0;
......
......@@ -94,7 +94,7 @@ blt_bo_fill(drm_intel_bo *tmp_bo, drm_intel_bo *bo, uint8_t val)
if (bo->offset < mappable_gtt_limit &&
(IS_G33(devid) || intel_gen(devid) >= 4))
drmtest_trash_aperture();
igt_trash_aperture();
copy_bo(tmp_bo, bo);
}
......@@ -111,8 +111,8 @@ int main(int argc, char **argv)
uint8_t *cpu_ptr;
uint8_t *gtt_ptr;
drmtest_subtest_init(argc, argv);
drmtest_skip_on_simulation();
igt_subtest_init(argc, argv);
igt_skip_on_simulation();
srandom(0xdeadbeef);
......@@ -138,12 +138,12 @@ int main(int argc, char **argv)
staging_bo = drm_intel_bo_alloc(bufmgr, "staging bo", BO_SIZE, 4096);
drmtest_init_aperture_trashers(bufmgr);
igt_init_aperture_trashers(bufmgr);
mappable_gtt_limit = gem_mappable_aperture_size();
drmtest_subtest("reads") {
igt_subtest("reads") {
if (!(flags & TEST_READ))
drmtest_skip();
igt_skip();
printf("checking partial reads\n");
......@@ -167,13 +167,13 @@ int main(int argc, char **argv)
}
drm_intel_bo_unmap(scratch_bo);
drmtest_progress("partial reads test: ", i, ROUNDS);
igt_progress("partial reads test: ", i, ROUNDS);
}
}
drmtest_subtest("writes") {
igt_subtest("writes") {
if (!(flags & TEST_WRITE))
drmtest_skip();
igt_skip();
printf("checking partial writes\n");
......@@ -219,13 +219,13 @@ int main(int argc, char **argv)
}
drm_intel_gem_bo_unmap_gtt(staging_bo);
drmtest_progress("partial writes test: ", i, ROUNDS);
igt_progress("partial writes test: ", i, ROUNDS);
}
}
drmtest_subtest("read-writes") {
igt_subtest("read-writes") {
if (!((flags & TEST_BOTH) == TEST_BOTH))
drmtest_skip();
igt_skip();
printf("checking partial writes after partial reads\n");
......@@ -292,14 +292,14 @@ int main(int argc, char **argv)
drm_intel_gem_bo_unmap_gtt(staging_bo);
drm_intel_bo_unmap(scratch_bo);
drmtest_progress("partial read/writes test: ", i, ROUNDS);
igt_progress("partial read/writes test: ", i, ROUNDS);
}
}
drmtest_cleanup_aperture_trashers();
igt_cleanup_aperture_trashers();
drm_intel_bufmgr_destroy(bufmgr);
close(fd);
return drmtest_retval();
return igt_retval();
}
......@@ -95,8 +95,8 @@ main(int argc, char **argv)
int width = 512, height = 512;
int i, loop, fd;
drmtest_subtest_init(argc, argv);
drmtest_skip_on_simulation();
igt_subtest_init(argc, argv);
igt_skip_on_simulation();
fd = drm_open_any();
......@@ -108,7 +108,7 @@ main(int argc, char **argv)
drm_intel_bufmgr_gem_enable_reuse(bufmgr);
batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
if (!drmtest_only_list_subtests()) {
if (!igt_only_list_subtests()) {
for (i = 0; i < num_buffers; i++) {
src[i] = create_bo(bufmgr, i, width, height);
dst[i] = create_bo(bufmgr, ~i, width, height);
......@@ -117,7 +117,7 @@ main(int argc, char **argv)
}
/* try to overwrite the source values */