lib: Add 64-bit version of igt_assert_cmp
PATCH v2 1/2 lib: Add 64-bit version of igt_assert_cmp
igt_assert_cmp64 and its derivatives:
- igt_assert_cmpu64
- igt_assert_eq64
- igt_assert_eq_u64
- igt_assert_neq64
- igt_assert_lte64
- igt_assert_lt64
v2: Add igt_assert_cmp_t, this macro handles int, long and double var cases. (Chris)
--- lib/igt_core.h | 125 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 97 insertions(+), 28 deletions(-)
lib/igt_core.h +97 -28
@@ -323,6 +323,20 @@ void igt_exit(void) __attribute__((noreturn));*/ #define igt_fail_on_f(expr, f...) igt_assert_f(!(expr), f) +#define INTDECFORMAT "%d" +#define UINTHEXFORMAT "%#x" +#define DOUBLEDECFORMAT "%#lf" +#define LONGHEXFORMAT "%#llx" + +#define igt_assert_cmp_t (T ,F , n1, cmp, ncmp, n2) \ + do { \ + T __n1 = (n1), __n2 = (n2); \ + if (!(__n1 cmp __n2)) \ + __igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ + #n1 " " #cmp " " #n2, \ + "error: " F " " #ncmp " " F "\n", __n1, __n2); \ + } while (0) +/** * igt_assert_cmpint: * @n1: first value
@@ -333,18 +347,13 @@ void igt_exit(void) __attribute__((noreturn));* Fails (sub-)test if the condition is not met * * Should be used everywhere where a test compares two integer values. +* For 64-bit values use igt_assert_cmp64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression. */ #define igt_assert_cmpint (n1, cmp, ncmp, n2) \ - do { \ - int __n1 = (n1), __n2 = (n2); \ - if (__n1 cmp __n2) ; else \ - __igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ - #n1 " " #cmp " " #n2, \ - "error: %d " #ncmp " %d\n", __n1, __n2); \ - } while (0) + igt_assert_cmp_t(int, INTDECFORMAT, n1, cmp, ncmp, n2)/** * igt_assert_cmpuint:
@@ -353,16 +362,35 @@ void igt_exit(void) __attribute__((noreturn));* @ncmp: negated version of @cmp * @n2: second value * -* Like igt_assert_cmpint(), but for unsigned ints; +* Like igt_assert_cmpint(), but for unsigned ints. For 64-bit values +* use igt_assert_cmpu64(). */ #define igt_assert_cmpuint (n1, cmp, ncmp, n2) \ - do { \ - uint32_t __n1 = (n1), __n2 = (n2); \ - if (__n1 cmp __n2) ; else \ - __igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ - #n1 " " #cmp " " #n2, \ - "error: %#x " #ncmp " %#x\n", __n1, __n2); \ - } while (0) + igt_assert_cmp_t(uint32_t, UINTHEXFORMAT, n1, cmp, ncmp, n2) + +/** +* igt_assert_cmp64: +* @n1: first value +* @cmp: compare operator +* @ncmp: negated version of @cmp +* @n2: second value +* +* Like igt_assert_cmpint(), but for long longs; +*/ +#define igt_assert_cmp64 (n1, cmp, ncmp, n2) \ + igt_assert_cmp_t(long long, LONGHEXFORMAT, n1, cmp, ncmp, n2) + +/** +* igt_assert_cmpu64: +* @n1: first value +* @cmp: compare operator +* @ncmp: negated version of @cmp +* @n2: second value +* +* Like igt_assert_cmpint(), but for unsigned long longs; +*/ +#define igt_assert_cmpu64 (n1, cmp, ncmp, n2) \ + igt_assert_cmp_t(unsigned long long, LONGHEXFORMAT, n1, cmp, ncmp, n2)/** * igt_assert_cmpdouble:
@@ -374,21 +402,15 @@ void igt_exit(void) __attribute__((noreturn));* Like igt_assert_cmpint(), but for doubles; */ #define igt_assert_cmpdouble (n1, cmp, ncmp, n2) \ - do { \ - double __n1 = (n1), __n2 = (n2); \ - if (__n1 cmp __n2) ; else \ - __igt_fail_assert(IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ - #n1 " " #cmp " " #n2, \ - "error: %#lf " #ncmp " %#lf\n", __n1, __n2); \ - } while (0) + igt_assert_cmp_t(double, DOUBLEDECFORMAT, n1, cmp, ncmp, n2)/** * igt_assert_eq: * @n1: first integer * @n2: second integer * -* Fails (sub-)test if the two integers are not equal. Beware that for now this -* only works on integers. +* Fails (sub-)test if the two integers are not equal. Beware that this only +* works on integers. For 64-bit values, use igt_assert_eq64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression.
@@ -405,6 +427,24 @@ void igt_exit(void) __attribute__((noreturn));#define igt_assert_eq_u32 (n1, n2) igt_assert_cmpuint(n1, ==, !=, n2)/** +* igt_assert_eq64: +* @n1: first value +* @n2: second value +* +* Like igt_assert_eq(), but for long long. +*/ +#define igt_assert_eq64 (n1, n2) igt_assert_cmp64(n1, ==, !=, n2) + +/** +* igt_assert_eq_u64: +* @n1: first value +* @n2: second value +* +* Like igt_assert_eq(), but for unsigned long long. +*/ +#define igt_assert_eq_u64 (n1, n2) igt_assert_cmpu64(n1, ==, !=, n2) + +/** * igt_assert_eq_double: * @n1: first double * @n2: second double
@@ -418,8 +458,8 @@ void igt_exit(void) __attribute__((noreturn));* @n1: first integer * @n2: second integer * -* Fails (sub-)test if the two integers are equal. Beware that for now this -* only works on integers. +* Fails (sub-)test if the two integers are equal. Beware that this only works +* on integers. For 64-bit values, use igt_assert_neq64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression.
@@ -427,12 +467,22 @@ void igt_exit(void) __attribute__((noreturn));#define igt_assert_neq (n1, n2) igt_assert_cmpint(n1, !=, ==, n2)/** +* igt_assert_neq64: +* @n1: first value +* @n2: second value +* +* Like igt_assert_neq(), but for long long. +*/ +#define igt_assert_neq64 (n1, n2) igt_assert_cmp64(n1, !=, ==, n2) + +/** * igt_assert_lte: * @n1: first integer * @n2: second integer * * Fails (sub-)test if the second integers is greater than the first. -* Beware that for now this only works on integers. +* Beware that this only works on integers, for 64-bit values, use +* igt_assert_lte64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression.
@@ -440,12 +490,22 @@ void igt_exit(void) __attribute__((noreturn));#define igt_assert_lte (n1, n2) igt_assert_cmpint(n1, <=, >, n2)/** +* igt_assert_lte64: +* @n1: first value +* @n2: second value +* +* Like igt_assert_lte(), but for long long. +*/ +#define igt_assert_lte64 (n1, n2) igt_assert_cmp64(n1, <=, >, n2) + +/** * igt_assert_lt: * @n1: first integer * @n2: second integer * * Fails (sub-)test if the second integers is strictly smaller than the first. -* Beware that for now this only works on integers. +* Beware that this only works on integers. For 64-bit values, use +* igt_assert_lt64(). * * Like igt_assert(), but displays the values being compared on failure instead * of simply printing the stringified expression.
@@ -453,6 +513,15 @@ void igt_exit(void) __attribute__((noreturn));#define igt_assert_lt (n1, n2) igt_assert_cmpint(n1, <, >=, n2)/** +* igt_assert_lt64: +* @n1: first value +* @n2: second value +* +* Like igt_assert_lt(), but for long long. +*/ +#define igt_assert_lt64 (n1, n2) igt_assert_cmp64(n1, <, >=, n2) + +/** * igt_require: * @expr: condition to test *
Signature · 6 lines
2.4.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 lib/igt.cocci: Add 64-bit and float compare functions
Also include script output.
--- lib/igt.cocci | 42 +++++++++++++++++++++++++++++++ tests/gem_cs_tlb.c | 2 +- tests/kms_draw_crc.c | 6 ++--- tests/kms_frontbuffer_tracking.c | 54 ++++++++++++++++++++-------------------- tests/kms_panel_fitting.c | 2 +- tests/kms_pipe_b_c_ivb.c | 30 +++++++++++----------- tests/kms_plane_scaling.c | 2 +- tests/kms_rotation_crc.c | 4 +-- tests/pm_backlight.c | 20 +++++++-------- 9 files changed, 102 insertions(+), 60 deletions(-)
lib/igt.cocci +42 -0
@@ -174,6 +174,48 @@ int E3, E4; + igt_assert_lt(E3, E4); ) + +// Use comparison macros instead of raw igt_assert when possible (double variables) +@@ +double E1, E2; +@@ +( +- igt_assert(E1 == E2); ++ igt_assert_eq_double(E1, E2); +) + +// Use comparison macros instead of raw igt_assert when possible (64-bit variables) +@@ +typedef uint64_t; +uint64_t E1, E2; +long long E3, E4; +@@ +( +- igt_assert(E1 == E2); ++ igt_assert_eq_u64(E1, E2); +| +- igt_assert(E1 != E2); ++ igt_assert_neq64(E1, E2); +| +- igt_assert(E1 <= E2); ++ igt_assert_lte64(E1, E2); +| +- igt_assert(E1 < E2); ++ igt_assert_lt64(E1, E2); +| +- igt_assert(E3 == E4); ++ igt_assert_eq64(E3, E4); +| +- igt_assert(E3 != E4); ++ igt_assert_neq64(E3, E4); +| +- igt_assert(E3 <= E4); ++ igt_assert_lte64(E3, E4); +| +- igt_assert(E3 < E4); ++ igt_assert_lt64(E3, E4); +) + // avoid unused-result warnings when compiling with _FORTIFY_SOURCE defined @@ identifier func =~ "^(read|write)$";
tests/gem_cs_tlb.c +1 -1
@@ -135,7 +135,7 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)if (split >0 ) {/* Check that we've managed to collide in the tlb. */ -igt_assert (gtt_offset == gtt_offset_new); +igt_assert_eq_u64 (gtt_offset, gtt_offset_new);/* We hang onto the storage of the old batch by keeping * the cpu mmap around. */
tests/kms_draw_crc.c +3 -3
@@ -100,7 +100,7 @@ static void get_method_crc(enum igt_draw_method method, uint64_t tiling, rc =drmModeSetCrtc (drm_fd, ms.crtc_id, fb.fb_id,0 ,0 , &ms.connector_id,1 , ms.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );igt_pipe_crc_collect_crc (pipe_crc, crc);
@@ -141,7 +141,7 @@ static void get_fill_crc(uint64_t tiling, igt_crc_t *crc) rc =drmModeSetCrtc (drm_fd, ms.crtc_id, fb.fb_id,0 ,0 , &ms.connector_id,1 , ms.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );igt_pipe_crc_collect_crc (pipe_crc, crc);
@@ -167,7 +167,7 @@ static void fill_fb_subtest(void) rc =drmModeSetCrtc (drm_fd, ms.crtc_id, fb.fb_id,0 ,0 , &ms.connector_id,1 , ms.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );igt_pipe_crc_collect_crc (pipe_crc, &base_crc);
tests/kms_frontbuffer_tracking.c +27 -27
197 lines not on this page · raw message
tests/kms_panel_fitting.c +1 -1
@@ -127,7 +127,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, &output->id,1 , mode); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); }else {igt_display_commit2 (display, s); }
tests/kms_pipe_b_c_ivb.c +15 -15
@@ -96,7 +96,7 @@ set_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output) mode->hdisplay, mode->vdisplay,DRM_FORMAT_XRGB8888 ,I915_TILING_NONE , 1.0, 1.0, 1.0, &fb); -igt_assert (fb_id >=0 ); +igt_assert_lte (0 , fb_id);igt_plane_set_fb (primary, &fb);return igt_display_try_commit2 (&data->display,COMMIT_LEGACY );
@@ -152,12 +152,12 @@ test_dpms(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 );kmstest_set_connector_dpms (data->drm_fd, output1->config.connector,DRM_MODE_DPMS_OFF ); ret =set_big_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret !=0 ); +igt_assert_neq (ret,0 ); } static void
@@ -174,13 +174,13 @@ test_lane_reduction(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); } static void
@@ -197,16 +197,16 @@ test_disable_pipe_B(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =disable_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); } static void
@@ -223,13 +223,13 @@ test_from_C_to_B_with_3_lanes(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =disable_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); } static void
@@ -246,10 +246,10 @@ test_fail_enable_pipe_C_while_B_has_3_lanes(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret !=0 ); +igt_assert_neq (ret,0 ); }static data_t data;
tests/kms_plane_scaling.c +1 -1
@@ -129,7 +129,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, &output->id,1 , mode); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); }else {igt_display_commit2 (display, s); }
tests/kms_rotation_crc.c +2 -2
@@ -240,9 +240,9 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)igt_plane_set_rotation (plane, data->rotation); ret =igt_display_try_commit2 (display, commit);if (data->override_fmt || data->override_tiling) { -igt_assert (ret == -EINVAL ); +igt_assert_eq (ret, -EINVAL ); }else { -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 );igt_pipe_crc_collect_crc (data->pipe_crc, &crc_output); igt_assert_crc_equal(&data->ref_crc,
tests/pm_backlight.c +10 -10
@@ -95,12 +95,12 @@ static void test_and_verify(int val) {int result; -igt_assert (backlight_write (val,"brightness" ) ==0 ); -igt_assert (backlight_read (&result,"brightness" ) ==0 ); +igt_assert_eq (backlight_write (val,"brightness" ),0 ); +igt_assert_eq (backlight_read (&result,"brightness" ),0 );/* Check that the exact value sticks */ -igt_assert (result == val); +igt_assert_eq (result, val); -igt_assert (backlight_read (&result,"actual_brightness" ) ==0 ); +igt_assert_eq (backlight_read (&result,"actual_brightness" ),0 );/* Some rounding may happen depending on hw. Just check that it's close enough. */ igt_assert (result <= val + val *TOLERANCE /100 && result >= val - val *TOLERANCE /100 ); }
@@ -118,15 +118,15 @@ static void test_bad_brightness(int max)/* First write some sane value */ backlight_write (max /2 ,"brightness" );/* Writing invalid values should fail and not change the value */ -igt_assert (backlight_write (-1 ,"brightness" ) <0 ); +igt_assert_lt (backlight_write (-1 ,"brightness" ),0 );backlight_read (&val,"brightness" ); -igt_assert (val == max /2 ); -igt_assert (backlight_write (max +1 ,"brightness" ) <0 ); +igt_assert_eq (val, max /2 ); +igt_assert_lt (backlight_write (max +1 ,"brightness" ),0 );backlight_read (&val,"brightness" ); -igt_assert (val == max /2 ); -igt_assert (backlight_write (INT_MAX ,"brightness" ) <0 ); +igt_assert_eq (val, max /2 ); +igt_assert_lt (backlight_write (INT_MAX ,"brightness" ),0 );backlight_read (&val,"brightness" ); -igt_assert (val == max /2 ); +igt_assert_eq (val, max /2 ); }static void test_fade (int max)
Signature · 6 lines
2.4.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
tests/kms_frontbuffer_tracking.c static void setup_sink_crc(void) · line 1112
Quoted 6 lines · Michel Thierry
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);
This one is wrong, and similar transformations.
Quoted 22 lines
tests/kms_frontbuffer_tracking.c +2
-2rc =read (sink_crc.fd, crc.data,SINK_CRC_SIZE ); errno_ = errno;@@ -1184,7 +1184,7 @@ static bool fbc_supported_on_chipset(void)static void setup_fbc (void ) { fbc.fd =igt_debugfs_open ("i915_fbc_status" ,O_RDONLY ); -igt_assert (fbc.fd >=0 ); +igt_assert_lte (0 , fbc.fd);if (!fbc_supported_on_chipset ()) {igt_info ("Can't test FBC: not supported on this chipset\n" );@@ -1220,7 +1220,7 @@ static void setup_psr(void) } psr.fd =igt_debugfs_open ("i915_edp_psr_status" ,O_RDONLY ); -igt_assert (psr.fd >=0 ); +igt_assert_lte (0 , psr.fd);if (!psr_sink_has_support ()) {igt_info ("Can't test PSR: not supported by sink.\n" );
tests/kms_frontbuffer_tracking.c static void set_cursor_for_test(const struct test_mode *t, · line 1429
Quoted 5 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1426,13 +1426,13 @@ static void set_cursor_for_test(const struct test_mode *t,fill_fb_region (¶ms->cursor,0xFF0000FF ); rc =drmModeMoveCursor (drm.fd, params->crtc_id,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );
As a general comment, not on your patch, this assert doesn't provide anywhere near the right information. rc here is either -1 or 0, it's the errno that's interesting (fortunately also printed by the assert), but it is igt_assert_eq(drmModeModeCursor(drm.fd, params->crtc_id, 0, 0), 0); that provides the most useful immediate debugging aid.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
Quoted 9 lines · Chris Wilson
tests/kms_frontbuffer_tracking.c static void setup_sink_crc(void) · line 1112
Quoted 6 lines · Michel Thierry
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
I also saw it wrong at the beginning...
But, I think it's correct because coccinelle changed the operands order (the macro is checking for less-than or equals to).
- igt_assert(E3 <= E4);
+ igt_assert_lte(E3, E4);
Quoted 24 lines
Quoted 24 lines
tests/kms_frontbuffer_tracking.c +2
-2rc =read (sink_crc.fd, crc.data,SINK_CRC_SIZE ); errno_ = errno;@@ -1184,7 +1184,7 @@ static bool fbc_supported_on_chipset(void)static void setup_fbc (void ) { fbc.fd =igt_debugfs_open ("i915_fbc_status" ,O_RDONLY ); -igt_assert (fbc.fd >=0 ); +igt_assert_lte (0 , fbc.fd);if (!fbc_supported_on_chipset ()) {igt_info ("Can't test FBC: not supported on this chipset\n" );@@ -1220,7 +1220,7 @@ static void setup_psr(void) } psr.fd =igt_debugfs_open ("i915_edp_psr_status" ,O_RDONLY ); -igt_assert (psr.fd >=0 ); +igt_assert_lte (0 , psr.fd);if (!psr_sink_has_support ()) {igt_info ("Can't test PSR: not supported by sink.\n" );@@ -1426,13 +1426,13 @@ static void set_cursor_for_test(const struct test_mode *t,fill_fb_region (¶ms->cursor,0xFF0000FF );
Quoted 11 lines
tests/kms_frontbuffer_tracking.c static void set_cursor_for_test(const struct test_mode *t, · line 1429
Quoted 3 lines
tests/kms_frontbuffer_tracking.c +1
-1rc =drmModeMoveCursor (drm.fd, params->crtc_id,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );As a general comment, not on your patch, this assert doesn't provide anywhere near the right information. rc here is either -1 or 0, it's the errno that's interesting (fortunately also printed by the assert), but it is
igt_assert_eq(drmModeModeCursor(drm.fd, params->crtc_id, 0, 0), 0); that provides the most useful immediate debugging aid.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
Quoted 11 lines · Michel Thierry
Quoted 9 lines · Chris Wilson
tests/kms_frontbuffer_tracking.c static void setup_sink_crc(void) · line 1112
Quoted 6 lines · Michel Thierry
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
Quoted 3 lines
I also saw it wrong at the beginning...
But, I think it's correct because coccinelle changed the operands order (the macro is checking for less-than or equals to).
Apparently my logic stinks. I was thinking that '<' was the logical opposite of '>=' and so that's what I then expected to see.
In this case, just igt_assert_fd(sink_crtc.fd) would be more useful. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
In reply to Chris Wilson2015-06-30 10:54 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 8 lines · Michel Thierry
Quoted 7 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
Maybe I'm not intelligent enough, but I _really_ think these inequality comparison macros are very hard to read, and the value they add does not compensate the readability problem they bring, especially since, as you pointed, in a lot of cases, the errno is what's important. I'd love to _not_ have that on IGT. The fact that you and Michel are discussing whether the macro is correct or not kinda proves my point on readability. I don't really want to check which one of you is correct because it's going to take some time reading the macro definition, and I've done it before and didn't like it. Reading the plain original assertion is always easy and instantaneous.
Also, most of the assertions on IGT are "just in case" assertions that should probably never happen. I'm in favor of the idea that we should only "instrument" the important assertions that are likely to fail, while all the others should just be readable.
Quoted 41 lines
Quoted 22 lines
rc = read(sink_crc.fd, crc.data, SINK_CRC_SIZE); errno_ = errno;tests/kms_frontbuffer_tracking.c +2
-2@@ -1184,7 +1184,7 @@ static bool fbc_supported_on_chipset(void)static void setup_fbc (void ) { fbc.fd =igt_debugfs_open ("i915_fbc_status" ,O_RDONLY ); -igt_assert (fbc.fd >=0 ); +igt_assert_lte (0 , fbc.fd);if (!fbc_supported_on_chipset ()) {igt_info ("Can't test FBC: not supported on this chipset\n" );@@ -1220,7 +1220,7 @@ static void setup_psr(void) } psr.fd =igt_debugfs_open ("i915_edp_psr_status" ,O_RDONLY ); -igt_assert (psr.fd >=0 ); +igt_assert_lte (0 , psr.fd);if (!psr_sink_has_support ()) {igt_info ("Can't test PSR: not supported by sink.\n" );tests/kms_frontbuffer_tracking.c static void set_cursor_for_test(const struct test_mode *t, · line 1429
Quoted 5 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1426,13 +1426,13 @@ static void set_cursor_for_test(const struct test_mode *t,fill_fb_region (¶ms->cursor,0xFF0000FF ); rc =drmModeMoveCursor (drm.fd, params->crtc_id,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );As a general comment, not on your patch, this assert doesn't provide anywhere near the right information. rc here is either -1 or 0, it's the errno that's interesting (fortunately also printed by the assert), but it is
igt_assert_eq(drmModeModeCursor(drm.fd, params->crtc_id, 0, 0), 0); that provides the most useful immediate debugging aid.
-Chris--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
Quoted 21 lines · Paulo Zanoni
2015-06-30 10:54 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 8 lines · Michel Thierry
Quoted 7 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
Maybe I'm not intelligent enough, but I _really_ think these inequality comparison macros are very hard to read, and the value they add does not compensate the readability problem they bring, especially since, as you pointed, in a lot of cases, the errno is what's important. I'd love to _not_ have that on IGT. The fact that you and Michel are discussing whether the macro is correct or not kinda proves my point on readability. I don't really want to check which one of you is correct because it's going to take some time reading the macro definition, and I've done it before and didn't like it. Reading the plain original assertion is always easy and instantaneous.
Quoted 4 lines
Also, most of the assertions on IGT are "just in case" assertions that should probably never happen. I'm in favor of the idea that we should only "instrument" the important assertions that are likely to fail, while all the others should just be readable.
Imo igt_assert_cmpint was definitely useful for all the "did the right value land" testcase. Many of those run in a loop and it's really useful to see what the expected vs. real value is imo. It has gotten a bit out of hand though, and some of the igt.cocci transforms that have been added where plain wrong.
But ignoring those hiccups I still think this is somewhat useful. -Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
Quoted 27 lines · Daniel Vetter
Quoted 21 lines · Paulo Zanoni
2015-06-30 10:54 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 8 lines · Michel Thierry
Quoted 7 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
Maybe I'm not intelligent enough, but I _really_ think these inequality comparison macros are very hard to read, and the value they add does not compensate the readability problem they bring, especially since, as you pointed, in a lot of cases, the errno is what's important. I'd love to _not_ have that on IGT. The fact that you and Michel are discussing whether the macro is correct or not kinda proves my point on readability. I don't really want to check which one of you is correct because it's going to take some time reading the macro definition, and I've done it before and didn't like it. Reading the plain original assertion is always easy and instantaneous.
Quoted 4 lines
Also, most of the assertions on IGT are "just in case" assertions that should probably never happen. I'm in favor of the idea that we should only "instrument" the important assertions that are likely to fail, while all the others should just be readable.
Quoted 8 lines
Imo
igt_assert_cmpintwas definitely useful for all the "did the right value land" testcase. Many of those run in a loop and it's really useful to see what the expected vs. real value is imo. It has gotten a bit out of hand though, and some of theigt.coccitransforms that have been added where plain wrong.But ignoring those hiccups I still think this is somewhat useful. -Daniel
At another company where we were trying to do pretty much this, we defined the assert-comparison macro to take the comparison operator as one of the arguments, thus not destroying readability quite as much:
thus assert(a >= b); was transformed to
insist(a, >=, b);
So the order of operands and the specific comparator remain clearly visible, rather than being interchanged or logically inverted, but the macro can still report both the expected and actual values, and the text of the expressions used for each of them and the comparator.
.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
2015-07-03 6:23 GMT-03:00 Dave Gordon <[email protected]>:
Quoted 48 lines · Daniel Vetter
Quoted 33 lines · Paulo Zanoni
Quoted 25 lines
2015-06-30 10:54 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 10 lines · Michel Thierry
Quoted 8 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
Maybe I'm not intelligent enough, but I _really_ think these inequality comparison macros are very hard to read, and the value they add does not compensate the readability problem they bring, especially since, as you pointed, in a lot of cases, the errno is what's important. I'd love to _not_ have that on IGT. The fact that you and Michel are discussing whether the macro is correct or not kinda proves my point on readability. I don't really want to check which one of you is correct because it's going to take some time reading the macro definition, and I've done it before and didn't like it. Reading the plain original assertion is always easy and instantaneous.
Quoted 4 lines
Also, most of the assertions on IGT are "just in case" assertions that should probably never happen. I'm in favor of the idea that we should only "instrument" the important assertions that are likely to fail, while all the others should just be readable.
Quoted 8 lines
Imo
igt_assert_cmpintwas definitely useful for all the "did the right value land" testcase. Many of those run in a loop and it's really useful to see what the expected vs. real value is imo. It has gotten a bit out of hand though, and some of theigt.coccitransforms that have been added where plain wrong.But ignoring those hiccups I still think this is somewhat useful. -Daniel
At another company where we were trying to do pretty much this, we defined the assert-comparison macro to take the comparison operator as one of the arguments, thus not destroying readability quite as much:
Quoted 8 lines
thus assert(a >= b); was transformed to
insist(a, >=, b);So the order of operands and the specific comparator remain clearly visible, rather than being interchanged or logically inverted, but the macro can still report both the expected and actual values, and the text of the expressions used for each of them and the comparator.
I like the idea, so I decided to look at how to implement that. I discovered that igt_assert_cmpint() used to be exactly what you described. Later we added the ncmp argument and started favoring the usage of _lte everywhere...
Quoted 2 lines
.Dave.
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
Quoted 58 lines · Paulo Zanoni
2015-07-03 6:23 GMT-03:00 Dave Gordon <[email protected]>:
Quoted 48 lines · Daniel Vetter
Quoted 33 lines · Paulo Zanoni
Quoted 25 lines
2015-06-30 10:54 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 10 lines · Michel Thierry
Quoted 8 lines
tests/kms_frontbuffer_tracking.c +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd);This one is wrong, and similar transformations.
Maybe I'm not intelligent enough, but I _really_ think these inequality comparison macros are very hard to read, and the value they add does not compensate the readability problem they bring, especially since, as you pointed, in a lot of cases, the errno is what's important. I'd love to _not_ have that on IGT. The fact that you and Michel are discussing whether the macro is correct or not kinda proves my point on readability. I don't really want to check which one of you is correct because it's going to take some time reading the macro definition, and I've done it before and didn't like it. Reading the plain original assertion is always easy and instantaneous.
Quoted 4 lines
Also, most of the assertions on IGT are "just in case" assertions that should probably never happen. I'm in favor of the idea that we should only "instrument" the important assertions that are likely to fail, while all the others should just be readable.
Quoted 8 lines
Imo
igt_assert_cmpintwas definitely useful for all the "did the right value land" testcase. Many of those run in a loop and it's really useful to see what the expected vs. real value is imo. It has gotten a bit out of hand though, and some of theigt.coccitransforms that have been added where plain wrong.But ignoring those hiccups I still think this is somewhat useful. -Daniel
At another company where we were trying to do pretty much this, we defined the assert-comparison macro to take the comparison operator as one of the arguments, thus not destroying readability quite as much:
Quoted 8 lines
thus assert(a >= b); was transformed to
insist(a, >=, b);So the order of operands and the specific comparator remain clearly visible, rather than being interchanged or logically inverted, but the macro can still report both the expected and actual values, and the text of the expressions used for each of them and the comparator.
Quoted 4 lines
I like the idea, so I decided to look at how to implement that. I discovered that
igt_assert_cmpint()used to be exactly what you described. Later we added the ncmp argument and started favoring the usage of_lteeverywhere...
Well I was the one who added igt_assert_cmpint, but I didn't add all the _lte/gte/eq variants. I don't have a personal opinion about this so I'm totally open to going back to only igt_assert_cmpint everywhere (with cocci this is easy). But we'd need someone to push the discussion and get acks from everyone who seems to care (you have mine already). Matt Roper and Thomas Wood are probably the ones to poke.
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
Quoted 64 lines · Daniel Vetter
Quoted 58 lines · Paulo Zanoni
2015-07-03 6:23 GMT-03:00 Dave Gordon <[email protected]>:
Quoted 48 lines · Daniel Vetter
Quoted 33 lines · Paulo Zanoni
Quoted 25 lines
2015-06-30 10:54 GMT-03:00 Chris Wilson <[email protected]>:
Quoted 10 lines · Michel Thierry
Quoted 8 lines
(quoted diff) +1
-1@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void) set_mode_for_params(&prim_mode_params); sink_crc.fd = igt_debugfs_open("i915_sink_crc_eDP1", O_RDONLY); - igt_assert(sink_crc.fd >= 0); + igt_assert_lte(0, sink_crc.fd);This one is wrong, and similar transformations.
Maybe I'm not intelligent enough, but I _really_ think these inequality comparison macros are very hard to read, and the value they add does not compensate the readability problem they bring, especially since, as you pointed, in a lot of cases, the errno is what's important. I'd love to _not_ have that on IGT. The fact that you and Michel are discussing whether the macro is correct or not kinda proves my point on readability. I don't really want to check which one of you is correct because it's going to take some time reading the macro definition, and I've done it before and didn't like it. Reading the plain original assertion is always easy and instantaneous.
Quoted 4 lines
Also, most of the assertions on IGT are "just in case" assertions that should probably never happen. I'm in favor of the idea that we should only "instrument" the important assertions that are likely to fail, while all the others should just be readable.
Quoted 8 lines
Imo
igt_assert_cmpintwas definitely useful for all the "did the right value land" testcase. Many of those run in a loop and it's really useful to see what the expected vs. real value is imo. It has gotten a bit out of hand though, and some of theigt.coccitransforms that have been added where plain wrong.But ignoring those hiccups I still think this is somewhat useful. -Daniel
At another company where we were trying to do pretty much this, we defined the assert-comparison macro to take the comparison operator as one of the arguments, thus not destroying readability quite as much:
Quoted 8 lines
thus assert(a >= b); was transformed to
insist(a, >=, b);So the order of operands and the specific comparator remain clearly visible, rather than being interchanged or logically inverted, but the macro can still report both the expected and actual values, and the text of the expressions used for each of them and the comparator.
Quoted 4 lines
I like the idea, so I decided to look at how to implement that. I discovered that
igt_assert_cmpint()used to be exactly what you described. Later we added the ncmp argument and started favoring the usage of_lteeverywhere...
Quoted 6 lines
Well I was the one who added
igt_assert_cmpint, but I didn't add all the _lte/gte/eq variants. I don't have a personal opinion about this so I'm totally open to going back to onlyigt_assert_cmpinteverywhere (with cocci this is easy). But we'd need someone to push the discussion and get acks from everyone who seems to care (you have mine already). Matt Roper and Thomas Wood are probably the ones to poke.
Chris Wilson added the ncmp parameter to igt_assert_cmpint to make the output messages more readable, which lead to the various _lte/_eq/etc. variants.
Quoted 9 lines
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2 i-g-t] lib/igt.cocci: Add 64-bit and float compare functions
In reply to Michel Thierry2015-06-30 10:41 GMT-03:00 Michel Thierry <[email protected]>:
Quoted 4 lines
Also include script output.
Suggested-by Daniel Vetter <[email protected]>Signed-off-by Michel Thierry <[email protected]>
I've asked a few times already whether igt.cocci is a requirement or not, and nobody ever answered me. Can we please have an official answer/discussion before we merge a patch running igt.cocci on the whole codebase? See my previous emails for further arguments.
Quoted 517 lines
--- lib/igt.cocci | 42 +++++++++++++++++++++++++++++++ tests/gem_cs_tlb.c | 2 +- tests/kms_draw_crc.c | 6 ++--- tests/kms_frontbuffer_tracking.c | 54 ++++++++++++++++++++-------------------- tests/kms_panel_fitting.c | 2 +- tests/kms_pipe_b_c_ivb.c | 30 +++++++++++----------- tests/kms_plane_scaling.c | 2 +- tests/kms_rotation_crc.c | 4 +-- tests/pm_backlight.c | 20 +++++++-------- 9 files changed, 102 insertions(+), 60 deletions(-)lib/igt.cocci +42
-0@@ -174,6 +174,48 @@ int E3, E4; + igt_assert_lt(E3, E4); ) + +// Use comparison macros instead of raw igt_assert when possible (double variables) +@@ +double E1, E2; +@@ +( +- igt_assert(E1 == E2); ++ igt_assert_eq_double(E1, E2); +) + +// Use comparison macros instead of raw igt_assert when possible (64-bit variables) +@@ +typedef uint64_t; +uint64_t E1, E2; +long long E3, E4; +@@ +( +- igt_assert(E1 == E2); ++ igt_assert_eq_u64(E1, E2); +| +- igt_assert(E1 != E2); ++ igt_assert_neq64(E1, E2); +| +- igt_assert(E1 <= E2); ++ igt_assert_lte64(E1, E2); +| +- igt_assert(E1 < E2); ++ igt_assert_lt64(E1, E2); +| +- igt_assert(E3 == E4); ++ igt_assert_eq64(E3, E4); +| +- igt_assert(E3 != E4); ++ igt_assert_neq64(E3, E4); +| +- igt_assert(E3 <= E4); ++ igt_assert_lte64(E3, E4); +| +- igt_assert(E3 < E4); ++ igt_assert_lt64(E3, E4); +) + // avoid unused-result warnings when compiling with _FORTIFY_SOURCE defined @@ identifier func =~ "^(read|write)$";tests/gem_cs_tlb.c +1
-1@@ -135,7 +135,7 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)if (split >0 ) {/* Check that we've managed to collide in the tlb. */ -igt_assert (gtt_offset == gtt_offset_new); +igt_assert_eq_u64 (gtt_offset, gtt_offset_new);/* We hang onto the storage of the old batch by keeping * the cpu mmap around. */ tests/kms_draw_crc.c +3
-3@@ -100,7 +100,7 @@ static void get_method_crc(enum igt_draw_method method, uint64_t tiling, rc =drmModeSetCrtc (drm_fd, ms.crtc_id, fb.fb_id,0 ,0 , &ms.connector_id,1 , ms.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );igt_pipe_crc_collect_crc (pipe_crc, crc);@@ -141,7 +141,7 @@ static void get_fill_crc(uint64_t tiling, igt_crc_t *crc) rc =drmModeSetCrtc (drm_fd, ms.crtc_id, fb.fb_id,0 ,0 , &ms.connector_id,1 , ms.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );igt_pipe_crc_collect_crc (pipe_crc, crc);@@ -167,7 +167,7 @@ static void fill_fb_subtest(void) rc =drmModeSetCrtc (drm_fd, ms.crtc_id, fb.fb_id,0 ,0 , &ms.connector_id,1 , ms.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );igt_pipe_crc_collect_crc (pipe_crc, &base_crc);tests/kms_frontbuffer_tracking.c +27
-27@@ -821,7 +821,7 @@ static struct rect pat4_get_rect(struct fb_region *fb, int r) {struct rect rect; -igt_assert (r ==0 ); +igt_assert_eq (r,0 ); rect.x =0 ; rect.y =0 ;@@ -871,16 +871,16 @@ static void unset_all_crtcs(void)for (i =0 ; i < drm.res->count_crtcs; i++) { rc =drmModeSetCrtc (drm.fd, drm.res->crtcs[i],-1 ,0 ,0 ,NULL ,0 ,NULL ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 ); rc =drmModeSetCursor (drm.fd, drm.res->crtcs[i],0 ,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 ); }for (i =0 ; i < drm.planes->count_planes; i++) { rc =drmModeSetPlane (drm.fd, drm.planes->planes[i],0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 ); } }@@ -914,7 +914,7 @@ static void start_busy_thread(struct igt_fb *fb) busy_thread.height = fb->height; rc =pthread_create (&busy_thread.thread,NULL , busy_thread_func,NULL ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 ); }static void stop_busy_thread (void )@@ -967,7 +967,7 @@ static void init_blue_crc(void) rc =drmModeSetCrtc (drm.fd, prim_mode_params.crtc_id, blue.fb_id,0 ,0 , &prim_mode_params.connector_id,1 , prim_mode_params.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );collect_crcs (&blue_crc);print_crc ("Blue CRC: " , &blue_crc);@@ -1010,7 +1010,7 @@ static void init_crcs(struct draw_pattern_info *pattern) tmp_fbs[r].fb_id,0 ,0 , &prim_mode_params.connector_id,1 , prim_mode_params.mode); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );collect_crcs (&pattern->crcs[r]); }@@ -1109,7 +1109,7 @@ static void setup_sink_crc(void)set_mode_for_params (&prim_mode_params); sink_crc.fd =igt_debugfs_open ("i915_sink_crc_eDP1" ,O_RDONLY ); -igt_assert (sink_crc.fd >=0 ); +igt_assert_lte (0 , sink_crc.fd); rc =read (sink_crc.fd, crc.data,SINK_CRC_SIZE ); errno_ = errno;@@ -1184,7 +1184,7 @@ static bool fbc_supported_on_chipset(void)static void setup_fbc (void ) { fbc.fd =igt_debugfs_open ("i915_fbc_status" ,O_RDONLY ); -igt_assert (fbc.fd >=0 ); +igt_assert_lte (0 , fbc.fd);if (!fbc_supported_on_chipset ()) {igt_info ("Can't test FBC: not supported on this chipset\n" );@@ -1220,7 +1220,7 @@ static void setup_psr(void) } psr.fd =igt_debugfs_open ("i915_edp_psr_status" ,O_RDONLY ); -igt_assert (psr.fd >=0 ); +igt_assert_lte (0 , psr.fd);if (!psr_sink_has_support ()) {igt_info ("Can't test PSR: not supported by sink.\n" );@@ -1426,13 +1426,13 @@ static void set_cursor_for_test(const struct test_mode *t,fill_fb_region (¶ms->cursor,0xFF0000FF ); rc =drmModeMoveCursor (drm.fd, params->crtc_id,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 ); rc =drmModeSetCursor (drm.fd, params->crtc_id, params->cursor.fb->gem_handle, params->cursor.w, params->cursor.h); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );do_assertions (ASSERT_NO_ACTION_CHANGE ); }@@ -1449,7 +1449,7 @@ static void set_sprite_for_test(const struct test_mode *t, params->sprite.w, params->sprite.h,0 ,0 , params->sprite.w <<16 , params->sprite.h << 16); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );do_assertions (ASSERT_NO_ACTION_CHANGE ); }@@ -1830,7 +1830,7 @@ static void flip_subtest(const struct test_mode *t) rc =drmModePageFlip (drm.fd, params->crtc_id, params->fb.fb->fb_id,0 ,NULL ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );do_assertions (assertions); }@@ -1875,7 +1875,7 @@ static void move_subtest(const struct test_mode *t)case PLANE_CUR : rc =drmModeMoveCursor (drm.fd, params->crtc_id, rect.x, rect.y); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );break ;case PLANE_SPR : rc = drmModeSetPlane(drm.fd, params->sprite_id,@@ -1884,7 +1884,7 @@ static void move_subtest(const struct test_mode *t) rect.x, rect.y, rect.w, rect.h,0 ,0 , rect.w <<16 , rect.h << 16); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );break ;default :igt_assert (false);@@ -1936,13 +1936,13 @@ static void onoff_subtest(const struct test_mode *t)case PLANE_CUR : rc =drmModeSetCursor (drm.fd, params->crtc_id,0 ,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );break ;case PLANE_SPR : rc =drmModeSetPlane (drm.fd, params->sprite_id,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );break ;default :igt_assert (false);@@ -1956,7 +1956,7 @@ static void onoff_subtest(const struct test_mode *t) params->cursor.fb->gem_handle, params->cursor.w, params->cursor.h); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );break ;case PLANE_SPR : rc = drmModeSetPlane(drm.fd, params->sprite_id,@@ -1967,7 +1967,7 @@ static void onoff_subtest(const struct test_mode *t)0 , params->sprite.w <<16 , params->sprite.h << 16); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );break ;default :igt_assert (false);@@ -2014,7 +2014,7 @@ static void fullscreen_plane_subtest(const struct test_mode *t) fullscreen_fb.height,0 ,0 , fullscreen_fb.width <<16 , fullscreen_fb.height << 16); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );update_wanted_crc (t, &pattern->crcs[0 ]);switch (t->screen) {@@ -2032,7 +2032,7 @@ static void fullscreen_plane_subtest(const struct test_mode *t) rc =drmModeSetPlane (drm.fd, params->sprite_id,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ); -igt_assert (rc ==0 ); +igt_assert_eq (rc,0 );if (t->screen ==SCREEN_PRIM ) assertions =ASSERT_LAST_ACTION_CHANGED ;@@ -2114,23 +2114,23 @@ static int opt_handler(int option, int option_index, void *data) opt.step++;break ;case 'n' : -igt_assert (opt.only_feature ==FEATURE_COUNT ); +igt_assert_eq (opt.only_feature,FEATURE_COUNT ); opt.only_feature =FEATURE_NONE ;break ;case 'f' : -igt_assert (opt.only_feature ==FEATURE_COUNT ); +igt_assert_eq (opt.only_feature,FEATURE_COUNT ); opt.only_feature =FEATURE_FBC ;break ;case 'p' : -igt_assert (opt.only_feature ==FEATURE_COUNT ); +igt_assert_eq (opt.only_feature,FEATURE_COUNT ); opt.only_feature =FEATURE_PSR ;break ;case '1' : -igt_assert (opt.only_pipes ==PIPE_COUNT ); +igt_assert_eq (opt.only_pipes,PIPE_COUNT ); opt.only_pipes =PIPE_SINGLE ;break ;case '2' : -igt_assert (opt.only_pipes ==PIPE_COUNT ); +igt_assert_eq (opt.only_pipes,PIPE_COUNT ); opt.only_pipes =PIPE_DUAL ;break ;default :tests/kms_panel_fitting.c +1
-1@@ -127,7 +127,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, &output->id,1 , mode); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); }else {igt_display_commit2 (display, s); }tests/kms_pipe_b_c_ivb.c +15
-15@@ -96,7 +96,7 @@ set_mode_on_pipe(data_t *data, enum pipe pipe, igt_output_t *output) mode->hdisplay, mode->vdisplay,DRM_FORMAT_XRGB8888 ,I915_TILING_NONE , 1.0, 1.0, 1.0, &fb); -igt_assert (fb_id >=0 ); +igt_assert_lte (0 , fb_id);igt_plane_set_fb (primary, &fb);return igt_display_try_commit2 (&data->display,COMMIT_LEGACY );@@ -152,12 +152,12 @@ test_dpms(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 );kmstest_set_connector_dpms (data->drm_fd, output1->config.connector,DRM_MODE_DPMS_OFF ); ret =set_big_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret !=0 ); +igt_assert_neq (ret,0 ); } static void@@ -174,13 +174,13 @@ test_lane_reduction(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); } static void@@ -197,16 +197,16 @@ test_disable_pipe_B(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =disable_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); } static void@@ -223,13 +223,13 @@ test_from_C_to_B_with_3_lanes(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =disable_pipe (data,PIPE_C , output2); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); } static void@@ -246,10 +246,10 @@ test_fail_enable_pipe_C_while_B_has_3_lanes(data_t *data) kmstest_pipe_name(PIPE_C), igt_output_name(output2)); ret =set_big_mode_on_pipe (data,PIPE_B , output1); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); ret =set_normal_mode_on_pipe (data,PIPE_C , output2); -igt_assert (ret !=0 ); +igt_assert_neq (ret,0 ); }static data_t data;tests/kms_plane_scaling.c +1
-1@@ -129,7 +129,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe, &output->id,1 , mode); -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 ); }else {igt_display_commit2 (display, s); }tests/kms_rotation_crc.c +2
-2@@ -240,9 +240,9 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)igt_plane_set_rotation (plane, data->rotation); ret =igt_display_try_commit2 (display, commit);if (data->override_fmt || data->override_tiling) { -igt_assert (ret == -EINVAL ); +igt_assert_eq (ret, -EINVAL ); }else { -igt_assert (ret ==0 ); +igt_assert_eq (ret,0 );igt_pipe_crc_collect_crc (data->pipe_crc, &crc_output); igt_assert_crc_equal(&data->ref_crc,tests/pm_backlight.c +10
-11@@ -95,12 +95,12 @@ static void test_and_verify(int val) {int result; -igt_assert (backlight_write (val,"brightness" ) ==0 ); -igt_assert (backlight_read (&result,"brightness" ) ==0 ); +igt_assert_eq (backlight_write (val,"brightness" ),0 ); +igt_assert_eq (backlight_read (&result,"brightness" ),0 );/* Check that the exact value sticks */ -igt_assert (result == val); +igt_assert_eq (result, val); -igt_assert (backlight_read (&result,"actual_brightness" ) ==0 ); +igt_assert_eq (backlight_read (&result,"actual_brightness" ),0 );/* Some rounding may happen depending on hw. Just check that it's close enough. */ igt_assert (result <= val + val *TOLERANCE /100 && result >= val - val *TOLERANCE /100 ); }@@ -118,15 +118,15 @@ static void test_bad_brightness(int max)/* First write some sane value */ backlight_write (max /2 ,"brightness" );/* Writing invalid values should fail and not change the value */ -igt_assert (backlight_write (-1 ,"brightness" ) <0 ); +igt_assert_lt (backlight_write (-1 ,"brightness" ),0 );backlight_read (&val,"brightness" ); -igt_assert (val == max /2 ); -igt_assert (backlight_write (max +1 ,"brightness" ) <0 ); +igt_assert_eq (val, max /2 ); +igt_assert_lt (backlight_write (max +1 ,"brightness" ),0 );backlight_read (&val,"brightness" ); -igt_assert (val == max /2 ); -igt_assert (backlight_write (INT_MAX ,"brightness" ) <0 ); +igt_assert_eq (val, max /2 ); +igt_assert_lt (backlight_write (INT_MAX ,"brightness" ),0 );backlight_read (&val,"brightness" ); -igt_assert (val == max /2 ); +igt_assert_eq (val, max /2 ); }static void test_fade (int max) --2.4.5
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Paulo Zanoni _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 22 lines · Michel Thierry
igt_assert_cmp64and its derivatives:
-igt_assert_cmpu64
-igt_assert_eq64
-igt_assert_eq_u64
-igt_assert_neq64
-igt_assert_lte64
-igt_assert_lt64v2: Add
igt_assert_cmp_t, this macro handles int, long and double var cases. (Chris)Cc Chris Wilson <[email protected]>Signed-off-by Michel Thierry <[email protected]>--- lib/igt_core.h | 125 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 97 insertions(+), 28 deletions(-)lib/igt_core.h +0
-0
lib/igt_core.h void igt_exit(void) __attribute__((noreturn)); · line 329
Quoted 7 lines
lib/igt_core.h +4
-0@@ -323,6 +323,20 @@ void igt_exit(void) __attribute__((noreturn));*/ #define igt_fail_on_f(expr, f...) igt_assert_f(!(expr), f) +#define INTDECFORMAT "%d" +#define UINTHEXFORMAT "%#x" +#define DOUBLEDECFORMAT "%#lf" +#define LONGHEXFORMAT "%#llx"
Any particular reason? Passing in "%d" or %d would have worked just as well, right?
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Chris Wilson
lib/igt_core.h void igt_exit(void) __attribute__((noreturn)); · line 329
Quoted 6 lines · Michel Thierry
igt_assert_cmp64and its derivatives:lib/igt_core.h +4
-0+#define INTDECFORMAT "%d" +#define UINTHEXFORMAT "%#x" +#define DOUBLEDECFORMAT "%#lf" +#define LONGHEXFORMAT "%#llx"Any particular reason? Passing in "%d" or %d would have worked just as well, right?
Not really, these defines are not needed. The format specifier can be passed directly.
Quoted 4 lines
Reviewed-by Chris Wilson <[email protected]>-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx