[28/33] Run igt_fail_warn_skip_on_f.cocci

Submitted by Lyude Paul on June 10, 2019, 3:03 p.m.

Details

Message ID 20190610150321.512-28-lyude@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in IGT - Trybot

Not browsing as part of any series.

Commit Message

Lyude Paul June 10, 2019, 3:03 p.m.
From: Lyude Paul <lyude@redhat.com>

This one ended up being surprisingly accurate! Replace open-coded
igt_fail_on_f(), igt_warn_on_f(), etc. with their respective macros

Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 lib/igt_chamelium_stream.c    |  4 ++--
 lib/igt_gt.c                  |  8 ++++----
 lib/igt_kmod.c                |  3 +--
 lib/igt_kms.c                 | 19 +++++++++----------
 lib/igt_pm.c                  |  8 +++-----
 tests/amdgpu/amd_abm.c        | 10 ++++------
 tests/i915/gem_linear_blits.c |  6 +++---
 tests/i915/gem_tiled_blits.c  |  6 +++---
 tests/kms_atomic_transition.c |  4 ++--
 tests/kms_hdmi_inject.c       |  8 ++++----
 tests/kms_plane.c             | 10 ++++++----
 tests/kms_vrr.c               |  3 +--
 tests/perf_pmu.c              |  6 +++---
 13 files changed, 45 insertions(+), 50 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/igt_chamelium_stream.c b/lib/igt_chamelium_stream.c
index a8cd19e5..d0a8ba05 100644
--- a/lib/igt_chamelium_stream.c
+++ b/lib/igt_chamelium_stream.c
@@ -566,7 +566,7 @@  error_client:
 
 void chamelium_stream_deinit(struct chamelium_stream *client)
 {
-	if (close(client->fd) != 0)
-		igt_warn("close failed: %s\n", strerror(errno));
+	igt_warn_on_f(close(client->fd) != 0,
+		      "close failed: %s\n", strerror(errno));
 	free(client);
 }
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 78e3cd08..aeb6d6ac 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -117,8 +117,8 @@  static void eat_error_state(int dev)
  */
 void igt_require_hang_ring(int fd, int ring)
 {
-	if (!igt_check_boolean_env_var("IGT_HANG", true))
-		igt_skip("hang injection disabled by user");
+	igt_skip_on_f(!igt_check_boolean_env_var("IGT_HANG", true),
+		      "hang injection disabled by user");
 
 	gem_require_ring(fd, ring);
 	gem_context_require_bannable(fd);
@@ -171,8 +171,8 @@  igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
 	 */
 	igt_require_gem(fd);
 
-	if (!igt_check_boolean_env_var("IGT_HANG", true))
-		igt_skip("hang injection disabled by user");
+	igt_skip_on_f(!igt_check_boolean_env_var("IGT_HANG", true),
+		      "hang injection disabled by user");
 	gem_context_require_bannable(fd);
 	if (!igt_check_boolean_env_var("IGT_HANG_WITHOUT_RESET", false))
 		igt_require(has_gpu_reset(fd));
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 91662eb3..3fbd0266 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -385,8 +385,7 @@  static void kmsg_dump(int fd)
 
 		while (getline(&line, &len, file) != -1) {
 			char *start = strchr(line, ':');
-			if (start)
-				igt_warn("%s", start + 2);
+			igt_warn_on_f(start, "%s", start + 2);
 		}
 
 		free(line);
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 27f17c2f..cf5afcec 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -942,9 +942,8 @@  bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
 		forced_connectors_device[len] = dir;
 	}
 
-	if (len >= MAX_CONNECTORS)
-		igt_warn("Connector limit reached, %s will not be reset\n",
-			 path);
+	igt_warn_on_f(len >= MAX_CONNECTORS,
+		      "Connector limit reached, %s will not be reset\n", path);
 
 	igt_debug("Connector %s is now forced %s\n", path, value);
 	igt_debug("Current forced connectors:\n");
@@ -1161,10 +1160,10 @@  static bool _kmstest_connector_config(int drm_fd, uint32_t connector_id,
 		goto err2;
 
 	if (!connector->count_modes) {
-		if (probe)
-			igt_warn("connector %d/%s-%d has no modes\n", connector_id,
-				kmstest_connector_type_str(connector->connector_type),
-				connector->connector_type_id);
+		igt_warn_on_f(probe, "connector %d/%s-%d has no modes\n",
+			      connector_id,
+			      kmstest_connector_type_str(connector->connector_type),
+			      connector->connector_type_id);
 		goto err2;
 	}
 
@@ -2514,9 +2513,9 @@  igt_output_t **__igt_pipe_populate_outputs(igt_display_t *display, igt_output_t
 					chosen_outputs[j] = output;
 			}
 
-			if (!found)
-				igt_warn("Output %s could not be assigned to a pipe\n",
-					 igt_output_name(output));
+			igt_warn_on_f(!found,
+				      "Output %s could not be assigned to a pipe\n",
+				      igt_output_name(output));
 		}
 	}
 
diff --git a/lib/igt_pm.c b/lib/igt_pm.c
index 8373c1a0..bc813aaa 100644
--- a/lib/igt_pm.c
+++ b/lib/igt_pm.c
@@ -125,9 +125,8 @@  static void igt_pm_audio_restore_runtime_pm(void)
 		  __igt_pm_audio_runtime_control);
 
 	ret = __igt_pm_audio_restore_runtime_pm();
-	if (ret)
-		igt_warn("Failed to restore runtime audio PM! (errno=%d)\n",
-			 ret);
+	igt_warn_on_f(ret, "Failed to restore runtime audio PM! (errno=%d)\n",
+		      ret);
 }
 
 static void __igt_pm_audio_runtime_exit_handler(int sig)
@@ -486,8 +485,7 @@  void igt_restore_runtime_pm(void)
 		  __igt_pm_runtime_control);
 
 	ret = __igt_restore_runtime_pm();
-	if (ret)
-		igt_warn("Failed to restore runtime PM! (errno=%d)\n", ret);
+	igt_warn_on_f(ret, "Failed to restore runtime PM! (errno=%d)\n", ret);
 
 	igt_pm_audio_restore_runtime_pm();
 }
diff --git a/tests/amdgpu/amd_abm.c b/tests/amdgpu/amd_abm.c
index b8077be4..cc423491 100644
--- a/tests/amdgpu/amd_abm.c
+++ b/tests/amdgpu/amd_abm.c
@@ -130,14 +130,12 @@  static void test_init(data_t *data)
 	ret = igt_debugfs_simple_read(data->debugfs, "amdgpu_current_backlight_pwm",
 			 buf, sizeof(buf));
 
-	if (ret < 0)
-		igt_skip("No current backlight debugfs entry.\n");
+	igt_skip_on_f(ret < 0, "No current backlight debugfs entry.\n");
 
 	ret = igt_debugfs_simple_read(data->debugfs, "amdgpu_target_backlight_pwm",
 			 buf, sizeof(buf));
 
-	if (ret < 0)
-		igt_skip("No target backlight debugfs entry.\n");
+	igt_skip_on_f(ret < 0, "No target backlight debugfs entry.\n");
 
 	abm_prop_exists = false;
 
@@ -152,8 +150,8 @@  static void test_init(data_t *data)
 			break;
 	}
 
-	if (!abm_prop_exists)
-		igt_skip("No abm level property on any connector.\n");
+	igt_skip_on_f(!abm_prop_exists,
+		      "No abm level property on any connector.\n");
 }
 
 
diff --git a/tests/i915/gem_linear_blits.c b/tests/i915/gem_linear_blits.c
index a5359288..3fbc4a07 100644
--- a/tests/i915/gem_linear_blits.c
+++ b/tests/i915/gem_linear_blits.c
@@ -148,9 +148,9 @@  check_bo(int fd, uint32_t handle, uint32_t val)
 
 	num_errors = 0;
 	for (i = 0; i < WIDTH*HEIGHT; i++) {
-		if (linear[i] != val && num_errors++ < 32)
-			igt_warn("[%08x] Expected 0x%08x, found 0x%08x (difference 0x%08x)\n",
-				 i * 4, val, linear[i], val ^ linear[i]);
+		igt_warn_on_f(linear[i] != val && num_errors++ < 32,
+			      "[%08x] Expected 0x%08x, found 0x%08x (difference 0x%08x)\n",
+			      i * 4, val, linear[i], val ^ linear[i]);
 		val++;
 	}
 	igt_assert_eq(num_errors, 0);
diff --git a/tests/i915/gem_tiled_blits.c b/tests/i915/gem_tiled_blits.c
index 28861d0b..9699b319 100644
--- a/tests/i915/gem_tiled_blits.c
+++ b/tests/i915/gem_tiled_blits.c
@@ -106,9 +106,9 @@  check_bo(drm_intel_bo *bo, uint32_t val)
 
 	num_errors = 0;
 	for (i = 0; i < 1024 * 1024 / 4; i++) {
-		if (linear[i] != val && num_errors++ < 32)
-			igt_warn("[%08x] Expected 0x%08x, found 0x%08x (difference 0x%08x)\n",
-				 i * 4, val, linear[i], val ^ linear[i]);
+		igt_warn_on_f(linear[i] != val && num_errors++ < 32,
+			      "[%08x] Expected 0x%08x, found 0x%08x (difference 0x%08x)\n",
+			      i * 4, val, linear[i], val ^ linear[i]);
 		val++;
 	}
 	igt_assert_eq(num_errors, 0);
diff --git a/tests/kms_atomic_transition.c b/tests/kms_atomic_transition.c
index 04dcdbe8..9298050c 100644
--- a/tests/kms_atomic_transition.c
+++ b/tests/kms_atomic_transition.c
@@ -513,8 +513,8 @@  run_transition_test(igt_display_t *display, enum pipe pipe, igt_output_t *output
 			break;
 		}
 
-		if (!ret)
-			igt_skip("Cannot run tests without proper size sprite planes\n");
+		igt_skip_on_f(!ret,
+			      "Cannot run tests without proper size sprite planes\n");
 	}
 
 	igt_display_commit2(display, COMMIT_ATOMIC);
diff --git a/tests/kms_hdmi_inject.c b/tests/kms_hdmi_inject.c
index 29bc2988..176fd511 100644
--- a/tests/kms_hdmi_inject.c
+++ b/tests/kms_hdmi_inject.c
@@ -95,8 +95,8 @@  hdmi_inject_4k(int drm_fd, drmModeConnector *connector)
 
 	kmstest_force_edid(drm_fd, connector, edid, length);
 
-	if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
-		igt_skip("Could not force connector on\n");
+	igt_skip_on_f(!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON),
+		      "Could not force connector on\n");
 
 	cid = connector->connector_id;
 
@@ -153,8 +153,8 @@  hdmi_inject_audio(int drm_fd, drmModeConnector *connector)
 
 	kmstest_force_edid(drm_fd, connector, edid, length);
 
-	if (!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON))
-		igt_skip("Could not force connector on\n");
+	igt_skip_on_f(!kmstest_force_connector(drm_fd, connector, FORCE_CONNECTOR_ON),
+		      "Could not force connector on\n");
 
 	cid = connector->connector_id;
 	connector = drmModeGetConnectorCurrent(drm_fd, cid);
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 6f30a95e..861d955a 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -593,10 +593,12 @@  static bool test_format_plane(data_t *data, enum pipe pipe,
 		if (format == DRM_FORMAT_C8)
 			set_legacy_lut(data, pipe, 0xfc00);
 
-		if (crc_mismatch_count)
-			igt_warn("CRC mismatches with format " IGT_FORMAT_FMT " on %s.%u with %d/%d solid colors tested (0x%X)\n",
-				 IGT_FORMAT_ARGS(format), kmstest_pipe_name(pipe),
-				 plane->index, crc_mismatch_count, (int)ARRAY_SIZE(colors), crc_mismatch_mask);
+		igt_warn_on_f(crc_mismatch_count,
+			      "CRC mismatches with format " IGT_FORMAT_FMT " on %s.%u with %d/%d solid colors tested (0x%X)\n",
+			      IGT_FORMAT_ARGS(format),
+			      kmstest_pipe_name(pipe), plane->index,
+			      crc_mismatch_count, (int)ARRAY_SIZE(colors),
+			      crc_mismatch_mask);
 	}
 
 	igt_pipe_crc_stop(data->pipe_crc);
diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index 0981145e..d7b2a11a 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -384,8 +384,7 @@  run_vrr_test(data_t *data, test_t test, uint32_t flags)
 			}
 	}
 
-	if (!found)
-		igt_skip("No vrr capable outputs found.\n");
+	igt_skip_on_f(!found, "No vrr capable outputs found.\n");
 }
 
 igt_main
diff --git a/tests/perf_pmu.c b/tests/perf_pmu.c
index 2cfbd368..a967d369 100644
--- a/tests/perf_pmu.c
+++ b/tests/perf_pmu.c
@@ -1354,9 +1354,9 @@  test_frequency(int gem_fd)
 	 * Restore min/max.
 	 */
 	igt_sysfs_set_u32(sysfs, "gt_min_freq_mhz", min_freq);
-	if (igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz") != min_freq)
-		igt_warn("Unable to restore min frequency to saved value [%u MHz], now %u MHz\n",
-			 min_freq, igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz"));
+	igt_warn_on_f(igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz") != min_freq,
+		      "Unable to restore min frequency to saved value [%u MHz], now %u MHz\n",
+		      min_freq, igt_sysfs_get_u32(sysfs, "gt_min_freq_mhz"));
 	close(fd);
 
 	igt_info("Min frequency: requested %.1f, actual %.1f\n",