diff mbox

[i-g-t,v10,17/21] lib/sw_sync: Add igt_require_sw_sync to enable skipping on no sw_sync support

Message ID 20161207025213.11669-18-robert.foss@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robert Foss Dec. 7, 2016, 2:52 a.m. UTC
Add igt_require_sw_sync to provide tests to skip if sw_sync support isn't
available on the host machine.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
 lib/sw_sync.c | 22 ++++++++++++++++++++++
 lib/sw_sync.h |  1 +
 2 files changed, 23 insertions(+)

Comments

Petri Latvala Dec. 7, 2016, 11:06 a.m. UTC | #1
On Tue, Dec 06, 2016 at 09:52:09PM -0500, Robert Foss wrote:
> Add igt_require_sw_sync to provide tests to skip if sw_sync support isn't
> available on the host machine.
> 
> Signed-off-by: Robert Foss <robert.foss@collabora.com>
> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
> ---
>  lib/sw_sync.c | 22 ++++++++++++++++++++++
>  lib/sw_sync.h |  1 +
>  2 files changed, 23 insertions(+)
> 
> diff --git a/lib/sw_sync.c b/lib/sw_sync.c
> index a2168f78..d4ecc898 100644
> --- a/lib/sw_sync.c
> +++ b/lib/sw_sync.c
> @@ -194,3 +194,25 @@ int sync_fence_count_status(int fd, int status)
>  	igt_assert_f(count >= 0, "No fences with supplied status found");
>  	return count;
>  }
> +
> +static bool kernel_has_sw_sync(void)
> +{
> +	bool err;
> +
> +	igt_ignore_warn(system("/sbin/modprobe -s r sw_sync"));
> +
> +	err = false;
> +	if (access(DEVFS_SW_SYNC, R_OK | W_OK) < 0) {
> +		char buf[128];
> +
> +		snprintf(buf, sizeof(buf), "%s/sw_sync", igt_debugfs_mount());
> +		err = access(DEBUGFS_SW_SYNC, R_OK | W_OK) < 0;
> +	}


Did you mean access(buf, R_OK | W_OK) here?


--
Petri Latvala
Robert Foss Dec. 7, 2016, 3:27 p.m. UTC | #2
On 2016-12-07 06:06 AM, Petri Latvala wrote:
> On Tue, Dec 06, 2016 at 09:52:09PM -0500, Robert Foss wrote:
>> Add igt_require_sw_sync to provide tests to skip if sw_sync support isn't
>> available on the host machine.
>>
>> Signed-off-by: Robert Foss <robert.foss@collabora.com>
>> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
>> ---
>>  lib/sw_sync.c | 22 ++++++++++++++++++++++
>>  lib/sw_sync.h |  1 +
>>  2 files changed, 23 insertions(+)
>>
>> diff --git a/lib/sw_sync.c b/lib/sw_sync.c
>> index a2168f78..d4ecc898 100644
>> --- a/lib/sw_sync.c
>> +++ b/lib/sw_sync.c
>> @@ -194,3 +194,25 @@ int sync_fence_count_status(int fd, int status)
>>  	igt_assert_f(count >= 0, "No fences with supplied status found");
>>  	return count;
>>  }
>> +
>> +static bool kernel_has_sw_sync(void)
>> +{
>> +	bool err;
>> +
>> +	igt_ignore_warn(system("/sbin/modprobe -s r sw_sync"));
>> +
>> +	err = false;
>> +	if (access(DEVFS_SW_SYNC, R_OK | W_OK) < 0) {
>> +		char buf[128];
>> +
>> +		snprintf(buf, sizeof(buf), "%s/sw_sync", igt_debugfs_mount());
>> +		err = access(DEBUGFS_SW_SYNC, R_OK | W_OK) < 0;
>> +	}
>
>
> Did you mean access(buf, R_OK | W_OK) here?

Yes, fixing this in v11.
Thanks!

>
>
> --
> Petri Latvala
>
diff mbox

Patch

diff --git a/lib/sw_sync.c b/lib/sw_sync.c
index a2168f78..d4ecc898 100644
--- a/lib/sw_sync.c
+++ b/lib/sw_sync.c
@@ -194,3 +194,25 @@  int sync_fence_count_status(int fd, int status)
 	igt_assert_f(count >= 0, "No fences with supplied status found");
 	return count;
 }
+
+static bool kernel_has_sw_sync(void)
+{
+	bool err;
+
+	igt_ignore_warn(system("/sbin/modprobe -s r sw_sync"));
+
+	err = false;
+	if (access(DEVFS_SW_SYNC, R_OK | W_OK) < 0) {
+		char buf[128];
+
+		snprintf(buf, sizeof(buf), "%s/sw_sync", igt_debugfs_mount());
+		err = access(DEBUGFS_SW_SYNC, R_OK | W_OK) < 0;
+	}
+
+	return !err;
+}
+
+void igt_require_sw_sync(void)
+{
+	igt_require(kernel_has_sw_sync());
+}
diff --git a/lib/sw_sync.h b/lib/sw_sync.h
index cea5a603..82af3378 100644
--- a/lib/sw_sync.h
+++ b/lib/sw_sync.h
@@ -39,6 +39,7 @@  int sync_merge(int fd1, int fd2);
 int sync_wait(int fence, int timeout);
 int sync_fence_count(int fd);
 int sync_fence_count_status(int fd, int status);
+void igt_require_sw_sync(void);
 
 #endif