* [PATCH i-g-t] tests: add core_setmaster_vs_auth
@ 2015-12-01 7:44 Daniel Vetter
2015-12-01 7:45 ` Daniel Vetter
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2015-12-01 7:44 UTC (permalink / raw)
To: Intel Graphics Development; +Cc: Daniel Vetter, Thomas Hellstrom, Daniel Vetter
Tests that master state isn't leaked to new masters by checking
that auth magics for the old master don't work any more.
Based upon a simple test program provided by Thomas.
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_setmaster_vs_auth.c | 73 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+)
create mode 100644 tests/core_setmaster_vs_auth.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 85936ea45c9f..43d63d3abac9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -4,6 +4,7 @@ core_getclient
core_getstats
core_getversion
core_prop_blob
+core_setmaster_vs_auth
drm_auth
drm_import_export
drm_read
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index ff178f7a2df4..b70bca060253 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -102,6 +102,7 @@ TESTS_progs = \
core_getstats \
core_getversion \
core_prop_blob \
+ core_setmaster_vs_auth \
drm_auth \
drm_import_export \
drm_read \
diff --git a/tests/core_setmaster_vs_auth.c b/tests/core_setmaster_vs_auth.c
new file mode 100644
index 000000000000..375b903e2352
--- /dev/null
+++ b/tests/core_setmaster_vs_auth.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Daniel Vetter <daniel.vetter@ffwll.ch>
+ *
+ * Based upon a test program provided by Thomas Hellstrom <thellstrom@vmware.com>
+ */
+
+/*
+ * Testcase: Check that drop/setMaster correctly transfer master state
+ *
+ * Test approach is only checking auth state (which is part of master state) by
+ * trying to authenticate a client against the wrong master.
+ */
+
+#define _GNU_SOURCE
+#include "igt.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef __linux__
+# include <sys/syscall.h>
+#else
+# include <pthread.h>
+#endif
+
+igt_main
+{
+ int master1, master2, client;
+ drm_magic_t magic;
+
+ master1 = drm_open_driver(DRIVER_ANY);
+ do_or_die(drmSetMaster(master1));
+
+ /* Get an authentication magic from the first master */
+ client = drm_open_driver(DRIVER_ANY);
+ do_or_die(drmGetMagic(client, &magic));
+
+ /* Open an fd an make it master */
+ master2 = drm_open_driver(DRIVER_ANY);
+ do_or_die(drmDropMaster(master1));
+ do_or_die(drmSetMaster(master2));
+
+ /* auth shouldn't work any more since the master we have the magic from
+ * isn't the current master any more. */
+ igt_assert_neq(drmAuthMagic(master2, magic), 0);
+ igt_assert_eq(errno, EINVAL);
+
+ close(client);
+ close(master2);
+ close(master1);
+}
--
2.1.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH i-g-t] tests: add core_setmaster_vs_auth
2015-12-01 7:44 [PATCH i-g-t] tests: add core_setmaster_vs_auth Daniel Vetter
@ 2015-12-01 7:45 ` Daniel Vetter
2015-12-01 14:27 ` Thomas Hellstrom
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2015-12-01 7:45 UTC (permalink / raw)
To: Intel Graphics Development; +Cc: Daniel Vetter, Thomas Hellstrom, Daniel Vetter
Tests that master state isn't leaked to new masters by checking
that auth magics for the old master don't work any more.
Based upon a simple test program provided by Thomas.
v2: Use correct test stanza ... and I need coffee.
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
tests/.gitignore | 1 +
tests/Makefile.sources | 1 +
tests/core_setmaster_vs_auth.c | 73 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+)
create mode 100644 tests/core_setmaster_vs_auth.c
diff --git a/tests/.gitignore b/tests/.gitignore
index 85936ea45c9f..43d63d3abac9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -4,6 +4,7 @@ core_getclient
core_getstats
core_getversion
core_prop_blob
+core_setmaster_vs_auth
drm_auth
drm_import_export
drm_read
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index ff178f7a2df4..b70bca060253 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -102,6 +102,7 @@ TESTS_progs = \
core_getstats \
core_getversion \
core_prop_blob \
+ core_setmaster_vs_auth \
drm_auth \
drm_import_export \
drm_read \
diff --git a/tests/core_setmaster_vs_auth.c b/tests/core_setmaster_vs_auth.c
new file mode 100644
index 000000000000..1d66044f7fe1
--- /dev/null
+++ b/tests/core_setmaster_vs_auth.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Daniel Vetter <daniel.vetter@ffwll.ch>
+ *
+ * Based upon a test program provided by Thomas Hellstrom <thellstrom@vmware.com>
+ */
+
+/*
+ * Testcase: Check that drop/setMaster correctly transfer master state
+ *
+ * Test approach is only checking auth state (which is part of master state) by
+ * trying to authenticate a client against the wrong master.
+ */
+
+#define _GNU_SOURCE
+#include "igt.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef __linux__
+# include <sys/syscall.h>
+#else
+# include <pthread.h>
+#endif
+
+igt_simple_main
+{
+ int master1, master2, client;
+ drm_magic_t magic;
+
+ master1 = drm_open_driver(DRIVER_ANY);
+ do_or_die(drmSetMaster(master1));
+
+ /* Get an authentication magic from the first master */
+ client = drm_open_driver(DRIVER_ANY);
+ do_or_die(drmGetMagic(client, &magic));
+
+ /* Open an fd an make it master */
+ master2 = drm_open_driver(DRIVER_ANY);
+ do_or_die(drmDropMaster(master1));
+ do_or_die(drmSetMaster(master2));
+
+ /* auth shouldn't work any more since the master we have the magic from
+ * isn't the current master any more. */
+ igt_assert_neq(drmAuthMagic(master2, magic), 0);
+ igt_assert_eq(errno, EINVAL);
+
+ close(client);
+ close(master2);
+ close(master1);
+}
--
2.1.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t] tests: add core_setmaster_vs_auth
2015-12-01 7:45 ` Daniel Vetter
@ 2015-12-01 14:27 ` Thomas Hellstrom
2015-12-01 16:45 ` Daniel Vetter
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Hellstrom @ 2015-12-01 14:27 UTC (permalink / raw)
To: Daniel Vetter, Intel Graphics Development; +Cc: Daniel Vetter
Daniel,
LGTM, except one comment below:
On 12/01/2015 08:45 AM, Daniel Vetter wrote:
> Tests that master state isn't leaked to new masters by checking
> that auth magics for the old master don't work any more.
>
> Based upon a simple test program provided by Thomas.
>
> v2: Use correct test stanza ... and I need coffee.
>
> Cc: Thomas Hellstrom <thellstrom@vmware.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> tests/.gitignore | 1 +
> tests/Makefile.sources | 1 +
> tests/core_setmaster_vs_auth.c | 73 ++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 75 insertions(+)
> create mode 100644 tests/core_setmaster_vs_auth.c
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 85936ea45c9f..43d63d3abac9 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -4,6 +4,7 @@ core_getclient
> core_getstats
> core_getversion
> core_prop_blob
> +core_setmaster_vs_auth
> drm_auth
> drm_import_export
> drm_read
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index ff178f7a2df4..b70bca060253 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -102,6 +102,7 @@ TESTS_progs = \
> core_getstats \
> core_getversion \
> core_prop_blob \
> + core_setmaster_vs_auth \
> drm_auth \
> drm_import_export \
> drm_read \
> diff --git a/tests/core_setmaster_vs_auth.c b/tests/core_setmaster_vs_auth.c
> new file mode 100644
> index 000000000000..1d66044f7fe1
> --- /dev/null
> +++ b/tests/core_setmaster_vs_auth.c
> @@ -0,0 +1,73 @@
> +/*
> + * Copyright © 2015 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + * Daniel Vetter <daniel.vetter@ffwll.ch>
> + *
> + * Based upon a test program provided by Thomas Hellstrom <thellstrom@vmware.com>
> + */
> +
> +/*
> + * Testcase: Check that drop/setMaster correctly transfer master state
> + *
> + * Test approach is only checking auth state (which is part of master state) by
> + * trying to authenticate a client against the wrong master.
> + */
> +
> +#define _GNU_SOURCE
> +#include "igt.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#ifdef __linux__
> +# include <sys/syscall.h>
> +#else
> +# include <pthread.h>
> +#endif
> +
> +igt_simple_main
> +{
> + int master1, master2, client;
> + drm_magic_t magic;
> +
> + master1 = drm_open_driver(DRIVER_ANY);
> + do_or_die(drmSetMaster(master1));
> +
> + /* Get an authentication magic from the first master */
> + client = drm_open_driver(DRIVER_ANY);
> + do_or_die(drmGetMagic(client, &magic));
> +
> + /* Open an fd an make it master */
> + master2 = drm_open_driver(DRIVER_ANY);
> + do_or_die(drmDropMaster(master1));
> + do_or_die(drmSetMaster(master2));
> +
> + /* auth shouldn't work any more since the master we have the magic from
> + * isn't the current master any more. */
Auth shouldn't work since we're authenticating with a different master than
the one we got the magic from.
> + igt_assert_neq(drmAuthMagic(master2, magic), 0);
> + igt_assert_eq(errno, EINVAL);
> +
> + close(client);
> + close(master2);
> + close(master1);
> +}
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t] tests: add core_setmaster_vs_auth
2015-12-01 14:27 ` Thomas Hellstrom
@ 2015-12-01 16:45 ` Daniel Vetter
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2015-12-01 16:45 UTC (permalink / raw)
To: Thomas Hellstrom; +Cc: Daniel Vetter, Intel Graphics Development, Daniel Vetter
On Tue, Dec 01, 2015 at 03:27:44PM +0100, Thomas Hellstrom wrote:
> Daniel,
>
> LGTM, except one comment below:
Thanks, I've updated the comment and pushed it out.
-Daniel
>
> On 12/01/2015 08:45 AM, Daniel Vetter wrote:
> > Tests that master state isn't leaked to new masters by checking
> > that auth magics for the old master don't work any more.
> >
> > Based upon a simple test program provided by Thomas.
> >
> > v2: Use correct test stanza ... and I need coffee.
> >
> > Cc: Thomas Hellstrom <thellstrom@vmware.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> > tests/.gitignore | 1 +
> > tests/Makefile.sources | 1 +
> > tests/core_setmaster_vs_auth.c | 73 ++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 75 insertions(+)
> > create mode 100644 tests/core_setmaster_vs_auth.c
> >
> > diff --git a/tests/.gitignore b/tests/.gitignore
> > index 85936ea45c9f..43d63d3abac9 100644
> > --- a/tests/.gitignore
> > +++ b/tests/.gitignore
> > @@ -4,6 +4,7 @@ core_getclient
> > core_getstats
> > core_getversion
> > core_prop_blob
> > +core_setmaster_vs_auth
> > drm_auth
> > drm_import_export
> > drm_read
> > diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> > index ff178f7a2df4..b70bca060253 100644
> > --- a/tests/Makefile.sources
> > +++ b/tests/Makefile.sources
> > @@ -102,6 +102,7 @@ TESTS_progs = \
> > core_getstats \
> > core_getversion \
> > core_prop_blob \
> > + core_setmaster_vs_auth \
> > drm_auth \
> > drm_import_export \
> > drm_read \
> > diff --git a/tests/core_setmaster_vs_auth.c b/tests/core_setmaster_vs_auth.c
> > new file mode 100644
> > index 000000000000..1d66044f7fe1
> > --- /dev/null
> > +++ b/tests/core_setmaster_vs_auth.c
> > @@ -0,0 +1,73 @@
> > +/*
> > + * Copyright © 2015 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the "Software"),
> > + * to deal in the Software without restriction, including without limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the next
> > + * paragraph) shall be included in all copies or substantial portions of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> > + * IN THE SOFTWARE.
> > + *
> > + * Authors:
> > + * Daniel Vetter <daniel.vetter@ffwll.ch>
> > + *
> > + * Based upon a test program provided by Thomas Hellstrom <thellstrom@vmware.com>
> > + */
> > +
> > +/*
> > + * Testcase: Check that drop/setMaster correctly transfer master state
> > + *
> > + * Test approach is only checking auth state (which is part of master state) by
> > + * trying to authenticate a client against the wrong master.
> > + */
> > +
> > +#define _GNU_SOURCE
> > +#include "igt.h"
> > +#include <unistd.h>
> > +#include <stdlib.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#ifdef __linux__
> > +# include <sys/syscall.h>
> > +#else
> > +# include <pthread.h>
> > +#endif
> > +
> > +igt_simple_main
> > +{
> > + int master1, master2, client;
> > + drm_magic_t magic;
> > +
> > + master1 = drm_open_driver(DRIVER_ANY);
> > + do_or_die(drmSetMaster(master1));
> > +
> > + /* Get an authentication magic from the first master */
> > + client = drm_open_driver(DRIVER_ANY);
> > + do_or_die(drmGetMagic(client, &magic));
> > +
> > + /* Open an fd an make it master */
> > + master2 = drm_open_driver(DRIVER_ANY);
> > + do_or_die(drmDropMaster(master1));
> > + do_or_die(drmSetMaster(master2));
> > +
> > + /* auth shouldn't work any more since the master we have the magic from
> > + * isn't the current master any more. */
>
> Auth shouldn't work since we're authenticating with a different master than
> the one we got the magic from.
>
> > + igt_assert_neq(drmAuthMagic(master2, magic), 0);
> > + igt_assert_eq(errno, EINVAL);
> > +
> > + close(client);
> > + close(master2);
> > + close(master1);
> > +}
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-01 16:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-01 7:44 [PATCH i-g-t] tests: add core_setmaster_vs_auth Daniel Vetter
2015-12-01 7:45 ` Daniel Vetter
2015-12-01 14:27 ` Thomas Hellstrom
2015-12-01 16:45 ` Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox