summaryrefslogtreecommitdiff
path: root/tests/pm_psr.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-05-14 09:56:53 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-05-14 09:56:53 +0200
commit0b7ce4ac2929ea56dfde508d551163a5304c66d8 (patch)
tree7af13f919437cc28ab61dbae3fee42a159fcfb6f /tests/pm_psr.c
parente624fa8a2e1a31494c6e47a65e378e480882422d (diff)
tests: Use igt macros more
Often just folding together of the common if (cond) printf; abort|igt_skip|igt_fail; pattern. But in a few cases I've ripped out more since the igt macros will already print the condition and errno. A few tests where more work (like ripping out return codes en masse) is needed left as-is. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/pm_psr.c')
-rw-r--r--tests/pm_psr.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/tests/pm_psr.c b/tests/pm_psr.c
index 4ba121f1..3ab7e7a0 100644
--- a/tests/pm_psr.c
+++ b/tests/pm_psr.c
@@ -38,44 +38,29 @@
static int get_perf(const char *path)
{
int ret, perf;
- bool sink, source, enabled;
FILE *file;
char str[4];
file = fopen(path, "r");
- if (file == NULL) {
- fprintf(stderr, "Couldn't open %s (%d)\n", path, errno);
- abort();
- }
+ igt_assert(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");
- sink = strcmp(str, "yes") == 0;
+ igt_skip_on_f(ret == 0,
+ "i915_edp_psr_status format not supported by this test case\n");
+ igt_require(strcmp(str, "yes") == 0);
ret = fscanf(file, "Source_OK: %s\n", str);
igt_assert(ret != 0);
- source = strcmp(str, "yes") == 0;
+
+ igt_require(strcmp(str, "yes") == 0);
+
ret = fscanf(file, "Enabled: %s\n", str);
igt_assert(ret != 0);
- enabled = strcmp(str, "yes") == 0;
+ igt_assert(strcmp(str, "yes") == 0);
+
ret = fscanf(file, "Performance_Counter: %i", &perf);
igt_assert(ret != 0);
- if (!sink)
- igt_skip("This panel does not support PSR.\n");
-
- if (!source)
- igt_skip("This Hardware does not support or isn't ready for PSR\n");
-
- if (!enabled) {
- fprintf(stderr, "PSR should be enabled\n");
- igt_fail(1);
- }
-
- if (perf == 0) {
- fprintf(stderr, "PSR state never achieved\n");
- igt_fail(1);
- }
+ igt_assert(perf);
fclose(file);
return perf;
@@ -96,8 +81,6 @@ igt_simple_main
sleep(SLEEP_DURATION / 1000);
perf2 = get_perf(path);
- if (perf1 == perf2) {
- fprintf(stderr, "Unable to enter PSR state again\n");
- igt_fail(1);
- }
+ igt_assert_f(perf1 != perf2,
+ "Unable to enter PSR state again\n");
}