All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] runner: Fix path handling
@ 2018-08-10 13:44 Arkadiusz Hiler
  2018-08-10 14:14 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arkadiusz Hiler @ 2018-08-10 13:44 UTC (permalink / raw)
  To: igt-dev

absolute_path() tends to return NULL if more than the last element of
the path is nonexistent. That behavior is confusing the callers, which
use NULL as a convention for something not being set at all.

Let's fix that by sprinkling a little bit of recursion onto
absolute_path() and wrapping POSIX in some sanity.

Cc: Petri Latvala <petri.latvala@intel.com>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
---
 runner/runner_tests.c | 22 ++++++--------------
 runner/settings.c     | 47 ++++++++++++++++++++++++++-----------------
 2 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/runner/runner_tests.c b/runner/runner_tests.c
index 7c662acc..89b4377a 100644
--- a/runner/runner_tests.c
+++ b/runner/runner_tests.c
@@ -231,28 +231,18 @@ igt_main
 		}
 
 		igt_subtest("absolute-path-converter") {
-			struct {
-				char *path;
-				bool null;
-			} data[] = { { "simple-name", false },
-				     { "foo/bar", true },
-				     { ".", false },
-			};
+			char paths[][15] = { "simple-name", "foo/bar", "." };
 			size_t i;
 
-			for (i = 0; i < ARRAY_SIZE(data); i++) {
+			for (i = 0; i < ARRAY_SIZE(paths); i++) {
 				free(path);
-				path = absolute_path(data[i].path);
-				if (data[i].null) {
-					igt_assert(path == NULL);
-					continue;
-				}
+				path = absolute_path(paths[i]);
 
 				igt_assert(path[0] == '/');
-				igt_debug("Got path %s for %s\n", path, data[i].path);
+				igt_debug("Got path %s for %s\n", path, paths[i]);
 				igt_assert(strstr(path, cwd) == path);
-				if (strcmp(data[i].path, ".")) {
-					igt_assert(strstr(path, data[i].path) != NULL);
+				if (strcmp(paths[i], ".")) {
+					igt_assert(strstr(path, paths[i]) != NULL);
 				}
 			}
 		}
diff --git a/runner/settings.c b/runner/settings.c
index 31754a12..060459b0 100644
--- a/runner/settings.c
+++ b/runner/settings.c
@@ -334,35 +334,44 @@ bool validate_settings(struct settings *settings)
 	return true;
 }
 
+static char *_dirname(const char *path)
+{
+	char *tmppath = strdup(path);
+	char *tmpname = dirname(tmppath);
+	tmpname = strdup(tmpname);
+	free(tmppath);
+	return tmpname;
+}
+
+static char *_basename(const char *path)
+{
+	char *tmppath = strdup(path);
+	char *tmpname = basename(tmppath);
+	tmpname = strdup(tmpname);
+	free(tmppath);
+	return tmpname;
+}
+
 char *absolute_path(char *path)
 {
 	char *result = NULL;
-	char *tmppath, *tmpname;
+	char *base, *dir;
+	char *ret;
 
 	result = realpath(path, NULL);
 	if (result != NULL)
 		return result;
 
-	tmppath = strdup(path);
-	tmpname = dirname(tmppath);
-	free(result);
-	result = realpath(tmpname, NULL);
-	free(tmppath);
+	dir = _dirname(path);
+	ret = absolute_path(dir);
+	free(dir);
 
-	if (result != NULL) {
-		char *ret;
+	base = _basename(path);
+	asprintf(&result, "%s/%s", ret, base);
+	free(base);
+	free(ret);
 
-		tmppath = strdup(path);
-		tmpname = basename(tmppath);
-
-		asprintf(&ret, "%s/%s", result, tmpname);
-		free(result);
-		free(tmppath);
-		return ret;
-	}
-
-	free(result);
-	return NULL;
+	return result;
 }
 
 static char settings_filename[] = "metadata.txt";
-- 
2.17.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for runner: Fix path handling
  2018-08-10 13:44 [igt-dev] [PATCH i-g-t] runner: Fix path handling Arkadiusz Hiler
@ 2018-08-10 14:14 ` Patchwork
  2018-08-10 18:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
  2018-08-13 10:20 ` [igt-dev] [PATCH i-g-t] " Petri Latvala
  2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-08-10 14:14 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

== Series Details ==

Series: runner: Fix path handling
URL   : https://patchwork.freedesktop.org/series/48018/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4642 -> IGTPW_1704 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/48018/revisions/1/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1704 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_workarounds:
      {fi-cfl-8109u}:     PASS -> DMESG-FAIL (fdo#107292)
      {fi-skl-iommu}:     PASS -> DMESG-FAIL (fdo#107292)
      fi-cnl-psr:         PASS -> DMESG-FAIL (fdo#107292)

    igt@gem_exec_suspend@basic-s4-devices:
      fi-kbl-7500u:       PASS -> DMESG-WARN (fdo#105128, fdo#107139)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-snb-2520m:       PASS -> INCOMPLETE (fdo#103713)

    {igt@kms_psr@sprite_plane_onoff}:
      {fi-bdw-samus}:     NOTRUN -> FAIL (fdo#107360)

    
    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload:
      fi-glk-j4005:       DMESG-WARN (fdo#106248, fdo#106725) -> PASS

    igt@drv_selftest@live_workarounds:
      {fi-bsw-kefka}:     DMESG-FAIL (fdo#107292) -> PASS
      fi-bdw-5557u:       DMESG-FAIL (fdo#107292) -> PASS

    igt@kms_flip@basic-flip-vs-wf_vblank:
      fi-glk-j4005:       FAIL (fdo#100368) -> PASS

    {igt@kms_psr@primary_mmap_gtt}:
      fi-cnl-psr:         DMESG-WARN (fdo#107372) -> PASS

    
    ==== Warnings ====

    {igt@kms_psr@primary_page_flip}:
      fi-cnl-psr:         DMESG-WARN (fdo#107372) -> DMESG-FAIL (fdo#107372)

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
  fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
  fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
  fdo#107139 https://bugs.freedesktop.org/show_bug.cgi?id=107139
  fdo#107292 https://bugs.freedesktop.org/show_bug.cgi?id=107292
  fdo#107360 https://bugs.freedesktop.org/show_bug.cgi?id=107360
  fdo#107372 https://bugs.freedesktop.org/show_bug.cgi?id=107372


== Participating hosts (53 -> 49) ==

  Additional (1): fi-bdw-samus 
  Missing    (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u 


== Build changes ==

    * IGT: IGT_4591 -> IGTPW_1704

  CI_DRM_4642: 0de4e9a02a422ebe523f59c3b462c949673746b6 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1704: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1704/
  IGT_4591: 6cb3d7dbe5831a7b2b5b7a4638d8a8b7ac624f5f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1704/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.IGT: success for runner: Fix path handling
  2018-08-10 13:44 [igt-dev] [PATCH i-g-t] runner: Fix path handling Arkadiusz Hiler
  2018-08-10 14:14 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-08-10 18:27 ` Patchwork
  2018-08-13 10:20 ` [igt-dev] [PATCH i-g-t] " Petri Latvala
  2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-08-10 18:27 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

== Series Details ==

Series: runner: Fix path handling
URL   : https://patchwork.freedesktop.org/series/48018/
State : success

== Summary ==

= CI Bug Log - changes from IGT_4591_full -> IGTPW_1704_full =

== Summary - WARNING ==

  Minor unknown changes coming with IGTPW_1704_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1704_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/48018/revisions/1/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1704_full:

  === IGT changes ===

    ==== Warnings ====

    igt@perf_pmu@rc6:
      shard-kbl:          PASS -> SKIP

    
== Known issues ==

  Here are the changes found in IGTPW_1704_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_exec_schedule@pi-ringfull-render:
      shard-glk:          NOTRUN -> FAIL (fdo#103158)

    igt@gem_wait@write-wait-default:
      shard-snb:          PASS -> INCOMPLETE (fdo#105411)

    igt@kms_cursor_legacy@all-pipes-torture-bo:
      shard-kbl:          PASS -> DMESG-WARN (fdo#107122)
      shard-apl:          PASS -> DMESG-WARN (fdo#107122)
      shard-snb:          PASS -> DMESG-WARN (fdo#107122)
      shard-glk:          NOTRUN -> DMESG-WARN (fdo#107122)

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt:
      shard-glk:          PASS -> FAIL (fdo#103167)

    igt@kms_rotation_crc@cursor-rotation-180:
      shard-hsw:          PASS -> FAIL (fdo#103925)

    igt@kms_rotation_crc@sprite-rotation-180:
      shard-snb:          PASS -> FAIL (fdo#103925)

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)

    
    ==== Possible fixes ====

    igt@gem_exec_store@basic-blt:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-snb:          FAIL (fdo#106641) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@kms_rotation_crc@primary-rotation-180:
      shard-snb:          FAIL (fdo#103925) -> PASS

    igt@pm_rpm@i2c:
      shard-apl:          FAIL (fdo#106539) -> PASS
      shard-glk:          FAIL (fdo#106539) -> PASS
      shard-hsw:          FAIL (fdo#106539) -> PASS
      shard-kbl:          FAIL (fdo#106539) -> PASS

    
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#106539 https://bugs.freedesktop.org/show_bug.cgi?id=106539
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
  fdo#107122 https://bugs.freedesktop.org/show_bug.cgi?id=107122
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * IGT: IGT_4591 -> IGTPW_1704
    * Linux: CI_DRM_4636 -> CI_DRM_4642

  CI_DRM_4636: 084bb2fb549650b6da80976c9bc594779ce342b4 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4642: 0de4e9a02a422ebe523f59c3b462c949673746b6 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1704: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1704/
  IGT_4591: 6cb3d7dbe5831a7b2b5b7a4638d8a8b7ac624f5f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1704/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [igt-dev] [PATCH i-g-t] runner: Fix path handling
  2018-08-10 13:44 [igt-dev] [PATCH i-g-t] runner: Fix path handling Arkadiusz Hiler
  2018-08-10 14:14 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
  2018-08-10 18:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
@ 2018-08-13 10:20 ` Petri Latvala
  2 siblings, 0 replies; 4+ messages in thread
From: Petri Latvala @ 2018-08-13 10:20 UTC (permalink / raw)
  To: Arkadiusz Hiler; +Cc: igt-dev

On Fri, Aug 10, 2018 at 04:44:46PM +0300, Arkadiusz Hiler wrote:
> absolute_path() tends to return NULL if more than the last element of
> the path is nonexistent. That behavior is confusing the callers, which
> use NULL as a convention for something not being set at all.
> 
> Let's fix that by sprinkling a little bit of recursion onto
> absolute_path() and wrapping POSIX in some sanity.
> 
> Cc: Petri Latvala <petri.latvala@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>


Reviewed-by: Petri Latvala <petri.latvala@intel.com>


... dunno what I was thinking, having weird semantics and even unit
tests that make sure the semantics are weird.



> ---
>  runner/runner_tests.c | 22 ++++++--------------
>  runner/settings.c     | 47 ++++++++++++++++++++++++++-----------------
>  2 files changed, 34 insertions(+), 35 deletions(-)
> 
> diff --git a/runner/runner_tests.c b/runner/runner_tests.c
> index 7c662acc..89b4377a 100644
> --- a/runner/runner_tests.c
> +++ b/runner/runner_tests.c
> @@ -231,28 +231,18 @@ igt_main
>  		}
>  
>  		igt_subtest("absolute-path-converter") {
> -			struct {
> -				char *path;
> -				bool null;
> -			} data[] = { { "simple-name", false },
> -				     { "foo/bar", true },
> -				     { ".", false },
> -			};
> +			char paths[][15] = { "simple-name", "foo/bar", "." };
>  			size_t i;
>  
> -			for (i = 0; i < ARRAY_SIZE(data); i++) {
> +			for (i = 0; i < ARRAY_SIZE(paths); i++) {
>  				free(path);
> -				path = absolute_path(data[i].path);
> -				if (data[i].null) {
> -					igt_assert(path == NULL);
> -					continue;
> -				}
> +				path = absolute_path(paths[i]);
>  
>  				igt_assert(path[0] == '/');
> -				igt_debug("Got path %s for %s\n", path, data[i].path);
> +				igt_debug("Got path %s for %s\n", path, paths[i]);
>  				igt_assert(strstr(path, cwd) == path);
> -				if (strcmp(data[i].path, ".")) {
> -					igt_assert(strstr(path, data[i].path) != NULL);
> +				if (strcmp(paths[i], ".")) {
> +					igt_assert(strstr(path, paths[i]) != NULL);
>  				}
>  			}
>  		}
> diff --git a/runner/settings.c b/runner/settings.c
> index 31754a12..060459b0 100644
> --- a/runner/settings.c
> +++ b/runner/settings.c
> @@ -334,35 +334,44 @@ bool validate_settings(struct settings *settings)
>  	return true;
>  }
>  
> +static char *_dirname(const char *path)
> +{
> +	char *tmppath = strdup(path);
> +	char *tmpname = dirname(tmppath);
> +	tmpname = strdup(tmpname);
> +	free(tmppath);
> +	return tmpname;
> +}
> +
> +static char *_basename(const char *path)
> +{
> +	char *tmppath = strdup(path);
> +	char *tmpname = basename(tmppath);
> +	tmpname = strdup(tmpname);
> +	free(tmppath);
> +	return tmpname;
> +}
> +
>  char *absolute_path(char *path)
>  {
>  	char *result = NULL;
> -	char *tmppath, *tmpname;
> +	char *base, *dir;
> +	char *ret;
>  
>  	result = realpath(path, NULL);
>  	if (result != NULL)
>  		return result;
>  
> -	tmppath = strdup(path);
> -	tmpname = dirname(tmppath);
> -	free(result);
> -	result = realpath(tmpname, NULL);
> -	free(tmppath);
> +	dir = _dirname(path);
> +	ret = absolute_path(dir);
> +	free(dir);
>  
> -	if (result != NULL) {
> -		char *ret;
> +	base = _basename(path);
> +	asprintf(&result, "%s/%s", ret, base);
> +	free(base);
> +	free(ret);
>  
> -		tmppath = strdup(path);
> -		tmpname = basename(tmppath);
> -
> -		asprintf(&ret, "%s/%s", result, tmpname);
> -		free(result);
> -		free(tmppath);
> -		return ret;
> -	}
> -
> -	free(result);
> -	return NULL;
> +	return result;
>  }
>  
>  static char settings_filename[] = "metadata.txt";
> -- 
> 2.17.1
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-13 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10 13:44 [igt-dev] [PATCH i-g-t] runner: Fix path handling Arkadiusz Hiler
2018-08-10 14:14 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-08-10 18:27 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-08-13 10:20 ` [igt-dev] [PATCH i-g-t] " Petri Latvala

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.