tests: Don't use stderr for informational messages
PATCH 1/5 tests: Don't use stderr for informational messages
These should go to stdout instead. The next patch will clean this up with cocci, so no change from fprintf(stdout, to printf( here.
--- lib/igt.cocci | 1 + tests/gem_stress.c | 2 +- tests/testdisplay.c | 34 +++++++++++++++++----------------- 3 files changed, 19 insertions(+), 18 deletions(-)
lib/igt.cocci +1 -0
@@ -1,3 +1,4 @@ +// Replace open-coded augmented igt_assert/skip/require with macro versions @@ expression Ec; expression list[n] Ep;
tests/gem_stress.c +1 -1
@@ -924,7 +924,7 @@ int main(int argc, char **argv)fan_in_and_check (); -fprintf (stderr,"num failed tiles %u, max incoherent bytes %zd\n" , +fprintf (stdou,"num failed tiles %u, max incoherent bytes %zd\n" , stats.num_failed, stats.max_failed_reads*sizeof (uint32_t ));intel_batchbuffer_free (batch);
tests/testdisplay.c +17 -17
@@ -675,22 +675,22 @@ static char optstr[] = "3hiaf:s:d:p:mrto:j:";static void __attribute__((noreturn))usage (char *name) { -fprintf (stderr,"usage: %s [-hiasdpmtf]\n" , name); -fprintf (stderr,"\t-i\tdump info\n" ); -fprintf (stderr,"\t-a\ttest all modes\n" ); -fprintf (stderr,"\t-s\t<duration>\tsleep between each mode test\n" ); -fprintf (stderr,"\t-d\t<depth>\tbit depth of scanout buffer\n" ); -fprintf (stderr,"\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n" ); -fprintf (stderr,"\t-m\ttest the preferred mode\n" ); -fprintf (stderr,"\t-3\ttest all 3D modes\n" ); -fprintf (stderr,"\t-t\tuse a tiled framebuffer\n" ); -fprintf (stderr,"\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n" ); -fprintf (stderr,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); -fprintf (stderr,"\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n" ); -fprintf (stderr,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" ); -fprintf (stderr,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" ); -fprintf (stderr,"\t\ttest force mode\n" ); -fprintf (stderr,"\tDefault is to test all modes.\n" ); +fprintf (stdout,"usage: %s [-hiasdpmtf]\n" , name); +fprintf (stdout,"\t-i\tdump info\n" ); +fprintf (stdout,"\t-a\ttest all modes\n" ); +fprintf (stdout,"\t-s\t<duration>\tsleep between each mode test\n" ); +fprintf (stdout,"\t-d\t<depth>\tbit depth of scanout buffer\n" ); +fprintf (stdout,"\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n" ); +fprintf (stdout,"\t-m\ttest the preferred mode\n" ); +fprintf (stdout,"\t-3\ttest all 3D modes\n" ); +fprintf (stdout,"\t-t\tuse a tiled framebuffer\n" ); +fprintf (stdout,"\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n" ); +fprintf (stdout,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); +fprintf (stdout,"\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n" ); +fprintf (stdout,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" ); +fprintf (stdout,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" ); +fprintf (stdout,"\t\ttest force mode\n" ); +fprintf (stdout,"\tDefault is to test all modes.\n" );exit (0 ); }
@@ -797,7 +797,7 @@ int main(int argc, char **argv)break ;case 'd' : depth =atoi (optarg); -fprintf (stderr,"using depth %d\n" , depth); +fprintf (stdout,"using depth %d\n" , depth);break ;case 'p' : if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width,
Signature · 1 line
2.0.0
PATCH 2/5 lib/igt.cocci: Conversion to igt logging
Also update old hunks to match on igt logging instead of fprintf.
--- lib/igt.cocci | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
lib/igt.cocci +24 -1
@@ -4,7 +4,13 @@ expression Ec; expression list[n] Ep; @@ - if (Ec) { -- fprintf( stderr, Ep ); +( +- igt_warn( Ep ); +| +- igt_info( Ep ); +| +- igt_debug( Ep ); +) - igt_fail(...); - } + igt_assert_f(Ec, Ep);
@@ -16,3 +22,20 @@ expression list[n] Ep; - igt_skip(Ep); - } + igt_skip_on_f(Ec, Ep); + +// Enforce use of logging functions +@@ +expression list[n] Ep; +@@ +-fprintf(stderr, Ep); ++igt_warn(Ep); +@@ +expression list[n] Ep; +@@ +-fprintf(stdout, Ep); ++igt_info(Ep); +@@ +expression list[n] Ep; +@@ +-printf(Ep); ++igt_info(Ep);
Signature · 1 line
2.0.0
PATCH 3/5 lib/igt.cocci: Convert abort() to igt_fail
In reply to Daniel Vetterabort should only be used for internal library checks - using abort() we get a "crash" result, using igt_fail we get "fail" in piglit.
--- lib/igt.cocci | 7 +++++++ 1 file changed, 7 insertions(+)
lib/igt.cocci +7 -0
@@ -39,3 +39,10 @@ expression list[n] Ep; @@ -printf(Ep); +igt_info(Ep); + +// No abort for tests, really. Should only be used for internal library checks +// in lib/* +@@ +@@ +-abort(); ++igt_fail(1);
Signature · 1 line
2.0.0
PATCH 4/5 lib/igt.cocci: Also add rule to use igt_warn_on_f
In reply to Daniel Vetter--- lib/igt.cocci | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/igt.cocci +8 -0
@@ -22,6 +22,14 @@ expression list[n] Ep; - igt_skip(Ep); - } + igt_skip_on_f(Ec, Ep); +@@ +expression Ec; +expression list[n] Ep; +@@ +- if (Ec) { +- igt_warn(Ep); +- } ++ igt_warn_on_f(Ec, Ep); // Enforce use of logging functions @@
Signature · 1 line
2.0.0
PATCH 5/5 tests: Run latest igt.cocci refactorings
In reply to Daniel VetterNeeds to be run a few times to reach a stable state ...
--- tests/ddi_compute_wrpll.c | 12 +---- tests/gem_bad_reloc.c | 4 +- tests/gem_fence_upload.c | 12 ++--- tests/gem_render_linear_blits.c | 2 +- tests/gem_render_tiled_blits.c | 2 +- tests/gem_ring_sync_copy.c | 2 +- tests/gem_seqno_wrap.c | 56 ++++++++++----------- tests/gem_stress.c | 84 +++++++++++++++----------------- tests/kms_fence_pin_leak.c | 4 +- tests/kms_psr_sink_crc.c | 10 ++-- tests/testdisplay.c | 105 ++++++++++++++++------------------------ tests/testdisplay_hotplug.c | 14 +++--- 12 files changed, 130 insertions(+), 177 deletions(-)
tests/ddi_compute_wrpll.c +2 -10
@@ -618,16 +618,8 @@ int main(void)unsigned r2, n2, p;wrpll_compute_rnp (ref->clock, &r2, &n2, &p); -if (ref->r2 != r2 || ref->n2 != n2 || ref->p != p) { -printf ("Computed value differs for %li Hz:\n" -" Reference: (%u,%u,%u)\n" -" Computed: (%u,%u,%u)\n" , - (int64_t )ref->clock *1000 , - ref->r2, ref->n2, ref->p, - r2, n2, p); - -abort (); - } +igt_assert_f (ref->r2 != r2 || ref->n2 != n2 || ref->p != p, +"Computed value differs for %li Hz:\n"" Reference: (%u,%u,%u)\n"" Computed: (%u,%u,%u)\n" , (int64_t )ref->clock *1000 , ref->r2, ref->n2, ref->p, r2, n2, p); }return 0 ;
tests/gem_bad_reloc.c +2 -2
@@ -86,7 +86,7 @@ static int negative_reloc(int fd, unsigned flags) &execbuf));gem_close (fd, gem_exec[1 ].handle); -printf ("Found offset %ld for 4k batch\n" , (long )gem_exec[0 ].offset); +igt_info ("Found offset %ld for 4k batch\n" , (long )gem_exec[0 ].offset);igt_require (gem_exec[0 ].offset <BIAS );memset (gem_reloc,0 ,sizeof (gem_reloc));
@@ -106,7 +106,7 @@ static int negative_reloc(int fd, unsigned flags)DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf)); -printf ("Batch is now at offset %ld\n" , (long )gem_exec[0 ].offset); +igt_info ("Batch is now at offset %ld\n" , (long )gem_exec[0 ].offset);gem_read (fd, gem_exec[0 ].handle,0 , buf,sizeof (buf));gem_close (fd, gem_exec[0 ].handle);
tests/gem_fence_upload.c +4 -8
@@ -81,8 +81,7 @@ static void performance(void)gettimeofday (&end,NULL ); linear[count !=2 ] = count * loop /elapsed (&start, &end); -printf ("Upload rate for %d linear surfaces: %7.3fMiB/s\n" , - count, linear[count !=2 ]); +igt_info ("Upload rate for %d linear surfaces: %7.3fMiB/s\n" , count, linear[count !=2 ]);for (n =0 ; n < count; n++)gem_set_tiling (fd, handle[n],I915_TILING_X ,1024 );
@@ -95,8 +94,7 @@ static void performance(void)gettimeofday (&end,NULL ); tiled[count !=2 ] = count * loop /elapsed (&start, &end); -printf ("Upload rate for %d tiled surfaces: %7.3fMiB/s\n" , - count, tiled[count !=2 ]); +igt_info ("Upload rate for %d tiled surfaces: %7.3fMiB/s\n" , count, tiled[count !=2 ]);for (n =0 ; n < count; n++) {munmap (ptr[n],OBJECT_SIZE );
@@ -215,8 +213,7 @@ static void thread_performance(unsigned mask)gettimeofday (&end,NULL ); linear[count !=2 ] = nthreads * loops /elapsed (&start, &end) / (OBJECT_SIZE /4096 ); -printf ("%s rate for %d linear surfaces, %d threads: %7.3fMiB/s\n" , -direction_string (mask), count, nthreads, linear[count !=2 ]); +igt_info ("%s rate for %d linear surfaces, %d threads: %7.3fMiB/s\n" ,direction_string (mask), count, nthreads, linear[count !=2 ]);for (n =0 ; n < count; n++)gem_set_tiling (fd, handle[n],I915_TILING_X ,1024 );
@@ -237,8 +234,7 @@ static void thread_performance(unsigned mask)gettimeofday (&end,NULL ); tiled[count !=2 ] = nthreads * loops /elapsed (&start, &end) / (OBJECT_SIZE /4096 ); -printf ("%s rate for %d tiled surfaces, %d threads: %7.3fMiB/s\n" , -direction_string (mask), count, nthreads, tiled[count !=2 ]); +igt_info ("%s rate for %d tiled surfaces, %d threads: %7.3fMiB/s\n" ,direction_string (mask), count, nthreads, tiled[count !=2 ]);for (n =0 ; n < count; n++) {munmap (ptr[n],OBJECT_SIZE );
tests/gem_render_linear_blits.c +1 -1
@@ -109,7 +109,7 @@ int main(int argc, char **argv)if (count ==0 ) count =3 *gem_aperture_size (fd) /SIZE /2 ;else if (count <2 ) { -fprintf (stderr,"count must be >= 2\n" ); +igt_warn ("count must be >= 2\n" );return 1 ; }
tests/gem_render_tiled_blits.c +1 -1
@@ -131,7 +131,7 @@ int main(int argc, char **argv)if (count ==0 ) count =3 *gem_aperture_size (fd) /SIZE /2 ;else if (count <2 ) { -fprintf (stderr,"count must be >= 2\n" ); +igt_warn ("count must be >= 2\n" );return 1 ; }
tests/gem_ring_sync_copy.c +1 -1
@@ -310,7 +310,7 @@ static void run_test(data_t *data, enum ring r1, enum ring r2, enum test test)bo_check (data, b,0xc );break ;default : -abort (); +igt_fail (1 ); } r1_ops->busy_fini (data);
tests/gem_seqno_wrap.c +25 -31
128 lines not on this page · raw message
tests/gem_stress.c +38 -46
231 lines not on this page · raw message
tests/kms_fence_pin_leak.c +2 -2
@@ -173,7 +173,7 @@ static bool run_single_test(data_t *data, enum pipe pipe, igt_output_t *output)igt_plane_set_fb (primary, &fb[!(i&1 )]);igt_display_commit (display); -printf ("." ); +igt_info ("." );fflush (stdout); }
@@ -184,7 +184,7 @@ static bool run_single_test(data_t *data, enum pipe pipe, igt_output_t *output)igt_remove_fb (data->drm_fd, &fb[1 ]);igt_remove_fb (data->drm_fd, &fb[0 ]); -printf ("\n" ); +igt_info ("\n" );return true; }
tests/kms_psr_sink_crc.c +5 -5
@@ -381,7 +381,7 @@ static void test_crc(data_t *data) ptr =gem_mmap__gtt (data->drm_fd, handle,4096 ,PROT_WRITE );gem_set_domain (data->drm_fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );memset (ptr,0xff ,4 );munmap (ptr,4096 );
@@ -390,12 +390,12 @@ static void test_crc(data_t *data) ptr =gem_mmap__gtt (data->drm_fd, handle,4096 ,PROT_WRITE );gem_set_domain (data->drm_fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );fill_blt (data, handle,0xff );igt_assert (wait_psr_entry (data,10 ));get_sink_crc (data, ref_crc); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );memset (ptr,0xff ,4 );munmap (ptr,4096 );
@@ -404,12 +404,12 @@ static void test_crc(data_t *data) ptr =gem_mmap__cpu (data->drm_fd, handle,4096 ,PROT_WRITE );gem_set_domain (data->drm_fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );fill_blt (data, handle,0xff );igt_assert (wait_psr_entry (data,10 ));get_sink_crc (data, ref_crc); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );memset (ptr,0xff ,4 );munmap (ptr,4096 );
tests/testdisplay.c +42 -63
216 lines not on this page · raw message
tests/testdisplay_hotplug.c +7 -7
@@ -69,13 +69,13 @@ gboolean testdisplay_setup_hotplug(void) udev =udev_new ();if (!udev) { -fprintf (stderr,"failed to create udev object\n" ); +igt_warn ("failed to create udev object\n" ); goto out; } uevent_monitor =udev_monitor_new_from_netlink (udev,"udev" );if (!uevent_monitor) { -fprintf (stderr,"failed to create udev event monitor\n" ); +igt_warn ("failed to create udev event monitor\n" ); goto out; }
@@ -83,27 +83,27 @@ gboolean testdisplay_setup_hotplug(void)"drm" , "drm_minor");if (ret <0 ) { -fprintf (stderr,"failed to filter for drm events\n" ); +igt_warn ("failed to filter for drm events\n" ); goto out; } ret =udev_monitor_enable_receiving (uevent_monitor);if (ret <0 ) { -fprintf (stderr,"failed to enable udev event reception\n" ); +igt_warn ("failed to enable udev event reception\n" ); goto out; } udevchannel =g_io_channel_unix_new (udev_monitor_get_fd (uevent_monitor));if (!udevchannel) { -fprintf (stderr,"failed to create udev GIO channel\n" ); +igt_warn ("failed to create udev GIO channel\n" ); goto out; } ret =g_io_add_watch (udevchannel,G_IO_IN |G_IO_ERR , hotplug_event, udev);if (ret <0 ) { -fprintf (stderr,"failed to add watch on udev GIO channel\n" ); +igt_warn ("failed to add watch on udev GIO channel\n" ); goto out; }
@@ -126,7 +126,7 @@ void testdisplay_cleanup_hotplug(void)#else gboolean testdisplay_setup_hotplug (void ) { -fprintf (stderr,"no hotplug support on this platform\n" ); +igt_warn ("no hotplug support on this platform\n" );return TRUE; }
Signature · 1 line
2.0.0
PATCH 1/1 NEWS: Mention igt.cocci
In reply to Daniel VetterAnd also pimp the spatch file itself with usage hints.
--- NEWS | 3 +++ lib/igt.cocci | 8 ++++++++ 2 files changed, 11 insertions(+)
NEWS +3 -0
@@ -1,6 +1,9 @@ Release 1.8 (xxxx-xx-xx) ------------------------ +- Added lib/igt.cocci semantic patch to catch often-seen patterns and convert + them to igt macros/infrastructure. + Release 1.7 (2014-06-09) ------------------------
lib/igt.cocci +8 -0
@@ -1,3 +1,11 @@ +// Semantic patch for common patters and their replacement by igt infrastructure +// and macros. Please run with +// +// spatch --sp-file lib/igt.cocci --in-place tests/*.c +// +// on your new testcase. + + // Replace open-coded augmented igt_assert/skip/require with macro versions @@ expression Ec;
Signature · 1 line
2.0.0
Quoted 24 lines · Daniel Vetter
These should go to stdout instead. The next patch will clean this up with cocci, so no change from fprintf(stdout, to printf( here.
Signed-off-by Daniel Vetter <[email protected]>--- lib/igt.cocci | 1 + tests/gem_stress.c | 2 +- tests/testdisplay.c | 34 +++++++++++++++++----------------- 3 files changed, 19 insertions(+), 18 deletions(-)lib/igt.cocci +1
-0@@ -1,3 +1,4 @@ +// Replace open-coded augmented igt_assert/skip/require with macro versions @@ expression Ec; expression list[n] Ep;tests/gem_stress.c +0
-0
tests/gem_stress.c int main(int argc, char **argv) · line 927
Quoted 5 lines
tests/gem_stress.c +1
-1@@ -924,7 +924,7 @@ int main(int argc, char **argv)fan_in_and_check (); - fprintf(stderr, "num failed tiles %u, max incoherent bytes %zd\n", + fprintf(stdou, "num failed tiles %u, max incoherent bytes %zd\n",
Ville spotted an s/stdou/stdout/ here, fixed up locally and re-run igt.cocci.
-Daniel
Quoted 58 lines
tests/gem_stress.c +0
-0stats.num_failed, stats.max_failed_reads*sizeof(uint32_t));intel_batchbuffer_free (batch);tests/testdisplay.c +17
-17@@ -675,22 +675,22 @@ static char optstr[] = "3hiaf:s:d:p:mrto:j:";static void __attribute__((noreturn))usage (char *name) { -fprintf (stderr,"usage: %s [-hiasdpmtf]\n" , name); -fprintf (stderr,"\t-i\tdump info\n" ); -fprintf (stderr,"\t-a\ttest all modes\n" ); -fprintf (stderr,"\t-s\t<duration>\tsleep between each mode test\n" ); -fprintf (stderr,"\t-d\t<depth>\tbit depth of scanout buffer\n" ); -fprintf (stderr,"\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n" ); -fprintf (stderr,"\t-m\ttest the preferred mode\n" ); -fprintf (stderr,"\t-3\ttest all 3D modes\n" ); -fprintf (stderr,"\t-t\tuse a tiled framebuffer\n" ); -fprintf (stderr,"\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n" ); -fprintf (stderr,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); -fprintf (stderr,"\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n" ); -fprintf (stderr,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" ); -fprintf (stderr,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" ); -fprintf (stderr,"\t\ttest force mode\n" ); -fprintf (stderr,"\tDefault is to test all modes.\n" ); +fprintf (stdout,"usage: %s [-hiasdpmtf]\n" , name); +fprintf (stdout,"\t-i\tdump info\n" ); +fprintf (stdout,"\t-a\ttest all modes\n" ); +fprintf (stdout,"\t-s\t<duration>\tsleep between each mode test\n" ); +fprintf (stdout,"\t-d\t<depth>\tbit depth of scanout buffer\n" ); +fprintf (stdout,"\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n" ); +fprintf (stdout,"\t-m\ttest the preferred mode\n" ); +fprintf (stdout,"\t-3\ttest all 3D modes\n" ); +fprintf (stdout,"\t-t\tuse a tiled framebuffer\n" ); +fprintf (stdout,"\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n" ); +fprintf (stdout,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); +fprintf (stdout,"\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n" ); +fprintf (stdout,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" ); +fprintf (stdout,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" ); +fprintf (stdout,"\t\ttest force mode\n" ); +fprintf (stdout,"\tDefault is to test all modes.\n" );exit (0 ); }@@ -797,7 +797,7 @@ int main(int argc, char **argv)break ;case 'd' : depth =atoi (optarg); -fprintf (stderr,"using depth %d\n" , depth); +fprintf (stdout,"using depth %d\n" , depth);break ;case 'p' : if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width,Signature · 1 line
2.0.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/8 tests/pm_psr_sink_crc: Fix longjmp fun
In reply to Daniel Vetterigt_fixture and igt_subtests use longjmp/setjmp internally, which means local variables at the same stack frame are at risk. Best practice is to move them out right in front of the igt_main block.
It would be awesome if someone could come up with a cocci patch to auto-fix this, but unfortunately my attempts failed.
--- tests/kms_psr_sink_crc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tests/kms_psr_sink_crc.c +3 -3
@@ -587,11 +587,11 @@ static void run_test(data_t *data) } } +data_t data = {}; +enum tests test; +igt_main { -data_t data = {}; -enum tests test; -igt_skip_on_simulation (); igt_fixture {
Signature · 1 line
2.0.0
PATCH 2/8 tests: Don't use stderr for informational messages
These should go to stdout instead. The next patch will clean this up with cocci, so no change from fprintf(stdout, to printf( here.
--- lib/igt.cocci | 1 + tests/gem_stress.c | 2 +- tests/testdisplay.c | 34 +++++++++++++++++----------------- 3 files changed, 19 insertions(+), 18 deletions(-)
lib/igt.cocci +1 -0
@@ -1,3 +1,4 @@ +// Replace open-coded augmented igt_assert/skip/require with macro versions @@ expression Ec; expression list[n] Ep;
tests/gem_stress.c +1 -1
@@ -924,7 +924,7 @@ int main(int argc, char **argv)fan_in_and_check (); -fprintf (stderr,"num failed tiles %u, max incoherent bytes %zd\n" , +fprintf (stdout,"num failed tiles %u, max incoherent bytes %zd\n" , stats.num_failed, stats.max_failed_reads*sizeof (uint32_t ));intel_batchbuffer_free (batch);
tests/testdisplay.c +17 -17
@@ -675,22 +675,22 @@ static char optstr[] = "3hiaf:s:d:p:mrto:j:";static void __attribute__((noreturn))usage (char *name) { -fprintf (stderr,"usage: %s [-hiasdpmtf]\n" , name); -fprintf (stderr,"\t-i\tdump info\n" ); -fprintf (stderr,"\t-a\ttest all modes\n" ); -fprintf (stderr,"\t-s\t<duration>\tsleep between each mode test\n" ); -fprintf (stderr,"\t-d\t<depth>\tbit depth of scanout buffer\n" ); -fprintf (stderr,"\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n" ); -fprintf (stderr,"\t-m\ttest the preferred mode\n" ); -fprintf (stderr,"\t-3\ttest all 3D modes\n" ); -fprintf (stderr,"\t-t\tuse a tiled framebuffer\n" ); -fprintf (stderr,"\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n" ); -fprintf (stderr,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); -fprintf (stderr,"\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n" ); -fprintf (stderr,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" ); -fprintf (stderr,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" ); -fprintf (stderr,"\t\ttest force mode\n" ); -fprintf (stderr,"\tDefault is to test all modes.\n" ); +fprintf (stdout,"usage: %s [-hiasdpmtf]\n" , name); +fprintf (stdout,"\t-i\tdump info\n" ); +fprintf (stdout,"\t-a\ttest all modes\n" ); +fprintf (stdout,"\t-s\t<duration>\tsleep between each mode test\n" ); +fprintf (stdout,"\t-d\t<depth>\tbit depth of scanout buffer\n" ); +fprintf (stdout,"\t-p\t<planew,h>,<crtcx,y>,<crtcw,h> test overlay plane\n" ); +fprintf (stdout,"\t-m\ttest the preferred mode\n" ); +fprintf (stdout,"\t-3\ttest all 3D modes\n" ); +fprintf (stdout,"\t-t\tuse a tiled framebuffer\n" ); +fprintf (stdout,"\t-j\tdo dpms off, optional arg to select dpms leve (1-3)\n" ); +fprintf (stdout,"\t-r\tprint a QR code on the screen whose content is \"pass\" for the automatic test\n" ); +fprintf (stdout,"\t-o\t<id of the display>,<number of the mode>\tonly test specified mode on the specified display\n" ); +fprintf (stdout,"\t-f\t<clock MHz>,<hdisp>,<hsync-start>,<hsync-end>,<htotal>,\n" ); +fprintf (stdout,"\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n" ); +fprintf (stdout,"\t\ttest force mode\n" ); +fprintf (stdout,"\tDefault is to test all modes.\n" );exit (0 ); }
@@ -797,7 +797,7 @@ int main(int argc, char **argv)break ;case 'd' : depth =atoi (optarg); -fprintf (stderr,"using depth %d\n" , depth); +fprintf (stdout,"using depth %d\n" , depth);break ;case 'p' : if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width,
Signature · 1 line
2.0.0
PATCH 3/8 lib/igt.cocci: Conversion to igt logging
In reply to Daniel VetterAlso update old hunks to match on igt logging instead of fprintf.
v2: Don't forget about perror.
--- lib/igt.cocci | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
lib/igt.cocci +29 -1
@@ -4,7 +4,13 @@ expression Ec; expression list[n] Ep; @@ - if (Ec) { -- fprintf( stderr, Ep ); +( +- igt_warn( Ep ); +| +- igt_info( Ep ); +| +- igt_debug( Ep ); +) - igt_fail(...); - } + igt_assert_f(Ec, Ep);
@@ -16,3 +22,25 @@ expression list[n] Ep; - igt_skip(Ep); - } + igt_skip_on_f(Ec, Ep); + +// Enforce use of logging functions +@@ +expression list[n] Ep; +@@ +-fprintf(stderr, Ep); ++igt_warn(Ep); +@@ +expression E; +@@ +-perror(E); ++igt_warn(E); +@@ +expression list[n] Ep; +@@ +-fprintf(stdout, Ep); ++igt_info(Ep); +@@ +expression list[n] Ep; +@@ +-printf(Ep); ++igt_info(Ep);
Signature · 1 line
2.0.0
PATCH 4/8 lib/igt.cocci: Convert abort() to igt_fail
In reply to Daniel Vetterabort should only be used for internal library checks - using abort() we get a "crash" result, using igt_fail we get "fail" in piglit.
--- lib/igt.cocci | 7 +++++++ 1 file changed, 7 insertions(+)
lib/igt.cocci +7 -0
@@ -44,3 +44,10 @@ expression list[n] Ep; @@ -printf(Ep); +igt_info(Ep); + +// No abort for tests, really. Should only be used for internal library checks +// in lib/* +@@ +@@ +-abort(); ++igt_fail(1);
Signature · 1 line
2.0.0
PATCH 5/8 lib/igt.cocci: Also add rule to use igt_warn_on_f
In reply to Daniel Vetter--- lib/igt.cocci | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/igt.cocci +8 -0
@@ -22,6 +22,14 @@ expression list[n] Ep; - igt_skip(Ep); - } + igt_skip_on_f(Ec, Ep); +@@ +expression Ec; +expression list[n] Ep; +@@ +- if (Ec) { +- igt_warn(Ep); +- } ++ igt_warn_on_f(Ec, Ep); // Enforce use of logging functions @@
Signature · 1 line
2.0.0
PATCH 6/8 lib: Introduce igt_fail_on/_f
In reply to Daniel VetterI've yet again totally screwed things up (this time automated with cocci even, but not yet pushed luckily). So finally add a new version for easier conversion and adjust the cocci script.
--- lib/igt.cocci | 9 ++++++++- lib/igt_core.h | 28 ++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-)
lib/igt.cocci +8 -1
@@ -13,7 +13,14 @@ expression list[n] Ep; ) - igt_fail(...); - } -+ igt_assert_f(Ec, Ep); ++ igt_fail_on_f(Ec, Ep); +@@ +expression Ec; +@@ +- if (Ec) { +- igt_fail(...); +- } ++ igt_fail_on(Ec); @@ expression Ec; expression list[n] Ep;
lib/igt_core.h +26 -2
@@ -204,7 +204,7 @@ void igt_exit(void) __attribute__((noreturn));* igt_assert: * @expr: condition to test * -* Fails (sub-)test if the condition is not met +* Fails (sub-)test if the condition is not met. * * Should be used everywhere where a test checks results. */
@@ -218,7 +218,7 @@ void igt_exit(void) __attribute__((noreturn));* @expr: condition to test * @...: format string and optional arguments * -* Fails (sub-)test if the condition is not met +* Fails (sub-)test if the condition is not met. * * Should be used everywhere where a test checks results. *
@@ -231,6 +231,30 @@ void igt_exit(void) __attribute__((noreturn)); }while (0 )/** +* igt_fail_on: +* @expr: condition to test +* +* Fails (sub-)test if the condition is met. +* +* Should be used everywhere where a test checks results. + */ +#define igt_fail_on (expr) igt_assert(!(expr)) + +/** +* igt_assert_f: +* @expr: condition to test +* @...: format string and optional arguments +* +* Fails (sub-)test if the condition is met. +* +* Should be used everywhere where a test checks results. +* +* In addition to the plain igt_assert() helper this allows to print additional +* information to help debugging test failures. +*/ +#define igt_fail_on_f(expr, f...) igt_assert_f(!(expr), f) + +/** * igt_assert_cmpint: * @n1: first value * @cmp: compare operator
Signature · 1 line
2.0.0
PATCH 7/8 NEWS: Mention igt.cocci
In reply to Daniel VetterAnd also pimp the spatch file itself with usage hints.
--- NEWS | 3 +++ lib/igt.cocci | 8 ++++++++ 2 files changed, 11 insertions(+)
NEWS +3 -0
@@ -1,6 +1,9 @@ Release 1.8 (xxxx-xx-xx) ------------------------ +- Added lib/igt.cocci semantic patch to catch often-seen patterns and convert + them to igt macros/infrastructure. + Release 1.7 (2014-06-09) ------------------------
lib/igt.cocci +8 -0
@@ -1,3 +1,11 @@ +// Semantic patch for common patters and their replacement by igt infrastructure +// and macros. Please run with +// +// spatch --sp-file lib/igt.cocci --in-place tests/*.c +// +// on your new testcase. + + // Replace open-coded augmented igt_assert/skip/require with macro versions @@ expression Ec;
Signature · 1 line
2.0.0
PATCH 8/8 tests: run igt.cocci
In reply to Daniel VetterRe-run with correct igt_fail rules. Again manually fixup missing includes for igt_core.h.
--- tests/ddi_compute_wrpll.c | 12 +---- tests/drv_hangman.c | 14 ++---- tests/gem_bad_reloc.c | 4 +- tests/gem_fence_upload.c | 18 +++---- tests/gem_reg_read.c | 6 +-- tests/gem_render_linear_blits.c | 2 +- tests/gem_render_tiled_blits.c | 2 +- tests/gem_ring_sync_copy.c | 2 +- tests/gem_seqno_wrap.c | 68 +++++++++++-------------- tests/gem_stress.c | 93 +++++++++++++++------------------- tests/kms_fence_pin_leak.c | 4 +- tests/kms_psr_sink_crc.c | 14 +++--- tests/testdisplay.c | 109 ++++++++++++++++------------------------ tests/testdisplay_hotplug.c | 16 +++--- 14 files changed, 152 insertions(+), 212 deletions(-)
tests/ddi_compute_wrpll.c +2 -10
@@ -618,16 +618,8 @@ int main(void)unsigned r2, n2, p;wrpll_compute_rnp (ref->clock, &r2, &n2, &p); -if (ref->r2 != r2 || ref->n2 != n2 || ref->p != p) { -printf ("Computed value differs for %li Hz:\n" -" Reference: (%u,%u,%u)\n" -" Computed: (%u,%u,%u)\n" , - (int64_t )ref->clock *1000 , - ref->r2, ref->n2, ref->p, - r2, n2, p); - -abort (); - } +igt_fail_on_f (ref->r2 != r2 || ref->n2 != n2 || ref->p != p, +"Computed value differs for %li Hz:\n"" Reference: (%u,%u,%u)\n"" Computed: (%u,%u,%u)\n" , (int64_t )ref->clock *1000 , ref->r2, ref->n2, ref->p, r2, n2, p); }return 0 ;
tests/drv_hangman.c +4 -10
@@ -118,17 +118,11 @@ static void _assert_dfs_entry(const char *fname, const char *s, bool inverse)read_dfs (fname, tmp, l +1 );if (!inverse) { -if (strncmp (tmp, s, l) !=0 ) { -fprintf (stderr,"contents of %s: '%s' (expected '%s')\n" , - fname, tmp, s); -igt_fail (1 ); - } +igt_fail_on_f (strncmp (tmp, s, l) !=0 , +"contents of %s: '%s' (expected '%s')\n" , fname, tmp, s); }else { -if (strncmp (tmp, s, l) ==0 ) { -fprintf (stderr,"contents of %s: '%s' (expected not '%s'\n" , - fname, tmp, s); -igt_fail (1 ); - } +igt_fail_on_f (strncmp (tmp, s, l) ==0 , +"contents of %s: '%s' (expected not '%s'\n" , fname, tmp, s); } }
tests/gem_bad_reloc.c +2 -2
@@ -86,7 +86,7 @@ static int negative_reloc(int fd, unsigned flags) &execbuf));gem_close (fd, gem_exec[1 ].handle); -printf ("Found offset %ld for 4k batch\n" , (long )gem_exec[0 ].offset); +igt_info ("Found offset %ld for 4k batch\n" , (long )gem_exec[0 ].offset);igt_require (gem_exec[0 ].offset <BIAS );memset (gem_reloc,0 ,sizeof (gem_reloc));
@@ -106,7 +106,7 @@ static int negative_reloc(int fd, unsigned flags)DRM_IOCTL_I915_GEM_EXECBUFFER2 , &execbuf)); -printf ("Batch is now at offset %ld\n" , (long )gem_exec[0 ].offset); +igt_info ("Batch is now at offset %ld\n" , (long )gem_exec[0 ].offset);gem_read (fd, gem_exec[0 ].handle,0 , buf,sizeof (buf));gem_close (fd, gem_exec[0 ].handle);
tests/gem_fence_upload.c +6 -12
@@ -81,8 +81,7 @@ static void performance(void)gettimeofday (&end,NULL ); linear[count !=2 ] = count * loop /elapsed (&start, &end); -printf ("Upload rate for %d linear surfaces: %7.3fMiB/s\n" , - count, linear[count !=2 ]); +igt_info ("Upload rate for %d linear surfaces: %7.3fMiB/s\n" , count, linear[count !=2 ]);for (n =0 ; n < count; n++)gem_set_tiling (fd, handle[n],I915_TILING_X ,1024 );
@@ -95,8 +94,7 @@ static void performance(void)gettimeofday (&end,NULL ); tiled[count !=2 ] = count * loop /elapsed (&start, &end); -printf ("Upload rate for %d tiled surfaces: %7.3fMiB/s\n" , - count, tiled[count !=2 ]); +igt_info ("Upload rate for %d tiled surfaces: %7.3fMiB/s\n" , count, tiled[count !=2 ]);for (n =0 ; n < count; n++) {munmap (ptr[n],OBJECT_SIZE );
@@ -215,8 +213,7 @@ static void thread_performance(unsigned mask)gettimeofday (&end,NULL ); linear[count !=2 ] = nthreads * loops /elapsed (&start, &end) / (OBJECT_SIZE /4096 ); -printf ("%s rate for %d linear surfaces, %d threads: %7.3fMiB/s\n" , -direction_string (mask), count, nthreads, linear[count !=2 ]); +igt_info ("%s rate for %d linear surfaces, %d threads: %7.3fMiB/s\n" ,direction_string (mask), count, nthreads, linear[count !=2 ]);for (n =0 ; n < count; n++)gem_set_tiling (fd, handle[n],I915_TILING_X ,1024 );
@@ -237,8 +234,7 @@ static void thread_performance(unsigned mask)gettimeofday (&end,NULL ); tiled[count !=2 ] = nthreads * loops /elapsed (&start, &end) / (OBJECT_SIZE /4096 ); -printf ("%s rate for %d tiled surfaces, %d threads: %7.3fMiB/s\n" , -direction_string (mask), count, nthreads, tiled[count !=2 ]); +igt_info ("%s rate for %d tiled surfaces, %d threads: %7.3fMiB/s\n" ,direction_string (mask), count, nthreads, tiled[count !=2 ]);for (n =0 ; n < count; n++) {munmap (ptr[n],OBJECT_SIZE );
@@ -300,8 +296,7 @@ static void thread_contention(void)gettimeofday (&end,NULL ); linear[count !=2 ] = count * loops /elapsed (&start, &end) / (OBJECT_SIZE /4096 ); -printf ("Contended upload rate for %d threads: %7.3fMiB/s\n" , - count, linear[count !=2 ]); +igt_info ("Contended upload rate for %d threads: %7.3fMiB/s\n" , count, linear[count !=2 ]);for (n =0 ; n < count; n++)gem_set_tiling (fd, threads[n].handle,I915_TILING_X ,1024 );
@@ -314,8 +309,7 @@ static void thread_contention(void)gettimeofday (&end,NULL ); tiled[count !=2 ] = count * loops /elapsed (&start, &end) / (OBJECT_SIZE /4096 ); -printf ("Contended upload rate for %d threads: %7.3fMiB/s\n" , - count, tiled[count !=2 ]); +igt_info ("Contended upload rate for %d threads: %7.3fMiB/s\n" , count, tiled[count !=2 ]);for (n =0 ; n < count; n++) {gem_close (fd, threads[n].handle);
tests/gem_reg_read.c +2 -4
@@ -44,10 +44,8 @@ static uint64_t timer_query(int fd)struct local_drm_i915_reg_read reg_read; reg_read.offset =0x2358 ; -if (drmIoctl (fd,REG_READ_IOCTL , ®_read)) { -perror ("positive test case failed: " ); -igt_fail (1 ); - } +igt_fail_on_f (drmIoctl (fd,REG_READ_IOCTL , ®_read), +"positive test case failed: " );return reg_read.val; }
tests/gem_render_linear_blits.c +1 -1
@@ -109,7 +109,7 @@ int main(int argc, char **argv)if (count ==0 ) count =3 *gem_aperture_size (fd) /SIZE /2 ;else if (count <2 ) { -fprintf (stderr,"count must be >= 2\n" ); +igt_warn ("count must be >= 2\n" );return 1 ; }
tests/gem_render_tiled_blits.c +1 -1
@@ -131,7 +131,7 @@ int main(int argc, char **argv)if (count ==0 ) count =3 *gem_aperture_size (fd) /SIZE /2 ;else if (count <2 ) { -fprintf (stderr,"count must be >= 2\n" ); +igt_warn ("count must be >= 2\n" );return 1 ; }
tests/gem_ring_sync_copy.c +1 -1
@@ -310,7 +310,7 @@ static void run_test(data_t *data, enum ring r1, enum ring r2, enum test test)bo_check (data, b,0xc );break ;default : -abort (); +igt_fail (1 ); } r1_ops->busy_fini (data);
tests/gem_seqno_wrap.c +30 -38
165 lines not on this page · raw message
tests/gem_stress.c +41 -52
252 lines not on this page · raw message
tests/kms_fence_pin_leak.c +2 -2
@@ -173,7 +173,7 @@ static bool run_single_test(data_t *data, enum pipe pipe, igt_output_t *output)igt_plane_set_fb (primary, &fb[!(i&1 )]);igt_display_commit (display); -printf ("." ); +igt_info ("." );fflush (stdout); }
@@ -184,7 +184,7 @@ static bool run_single_test(data_t *data, enum pipe pipe, igt_output_t *output)igt_remove_fb (data->drm_fd, &fb[1 ]);igt_remove_fb (data->drm_fd, &fb[0 ]); -printf ("\n" ); +igt_info ("\n" );return true; }
tests/kms_psr_sink_crc.c +7 -7
@@ -269,8 +269,8 @@ static bool psr_sink_support(data_t *data)igt_require (file); ret =fscanf (file,"Sink_Support: %s\n" , str); -if (ret ==0 ) -igt_skip ("i915_edp_psr_status format not supported by this test case\n" ); +igt_skip_on_f (ret ==0 , +"i915_edp_psr_status format not supported by this test case\n" );fclose (file);return strcmp (str,"yes" ) ==0 ;
@@ -381,7 +381,7 @@ static void test_crc(data_t *data) ptr =gem_mmap__gtt (data->drm_fd, handle,4096 ,PROT_WRITE );gem_set_domain (data->drm_fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );memset (ptr,0xff ,4 );munmap (ptr,4096 );
@@ -390,12 +390,12 @@ static void test_crc(data_t *data) ptr =gem_mmap__gtt (data->drm_fd, handle,4096 ,PROT_WRITE );gem_set_domain (data->drm_fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );fill_blt (data, handle,0xff );igt_assert (wait_psr_entry (data,10 ));get_sink_crc (data, ref_crc); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );memset (ptr,0xff ,4 );munmap (ptr,4096 );
@@ -404,12 +404,12 @@ static void test_crc(data_t *data) ptr =gem_mmap__cpu (data->drm_fd, handle,4096 ,PROT_WRITE );gem_set_domain (data->drm_fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );fill_blt (data, handle,0xff );igt_assert (wait_psr_entry (data,10 ));get_sink_crc (data, ref_crc); -fprintf (stdout,"Sleeping for 10 sec...\n" ); +igt_info ("Sleeping for 10 sec...\n" );sleep (10 );memset (ptr,0xff ,4 );munmap (ptr,4096 );
tests/testdisplay.c +44 -65
226 lines not on this page · raw message
tests/testdisplay_hotplug.c +9 -7
@@ -30,6 +30,8 @@#include "config.h" #endif +#include "igt_core.h" +#if HAVE_UDEV #include <libudev.h> static struct udev_monitor *uevent_monitor;
@@ -69,13 +71,13 @@ gboolean testdisplay_setup_hotplug(void) udev =udev_new ();if (!udev) { -fprintf (stderr,"failed to create udev object\n" ); +igt_warn ("failed to create udev object\n" ); goto out; } uevent_monitor =udev_monitor_new_from_netlink (udev,"udev" );if (!uevent_monitor) { -fprintf (stderr,"failed to create udev event monitor\n" ); +igt_warn ("failed to create udev event monitor\n" ); goto out; }
@@ -83,27 +85,27 @@ gboolean testdisplay_setup_hotplug(void)"drm" , "drm_minor");if (ret <0 ) { -fprintf (stderr,"failed to filter for drm events\n" ); +igt_warn ("failed to filter for drm events\n" ); goto out; } ret =udev_monitor_enable_receiving (uevent_monitor);if (ret <0 ) { -fprintf (stderr,"failed to enable udev event reception\n" ); +igt_warn ("failed to enable udev event reception\n" ); goto out; } udevchannel =g_io_channel_unix_new (udev_monitor_get_fd (uevent_monitor));if (!udevchannel) { -fprintf (stderr,"failed to create udev GIO channel\n" ); +igt_warn ("failed to create udev GIO channel\n" ); goto out; } ret =g_io_add_watch (udevchannel,G_IO_IN |G_IO_ERR , hotplug_event, udev);if (ret <0 ) { -fprintf (stderr,"failed to add watch on udev GIO channel\n" ); +igt_warn ("failed to add watch on udev GIO channel\n" ); goto out; }
@@ -126,7 +128,7 @@ void testdisplay_cleanup_hotplug(void)#else gboolean testdisplay_setup_hotplug (void ) { -fprintf (stderr,"no hotplug support on this platform\n" ); +igt_warn ("no hotplug support on this platform\n" );return TRUE; }
Signature · 1 line
2.0.0