[PATCH libdrm 2/3] tests/drmsl: Extract tests out of xf86drmSL.c

2015-03-26 Thread Emil Velikov
On 24/03/15 23:06, Jan Vesely wrote:
> v2: merge tests creation and xf86drmSL cleanup
> rename tests/drmsltest -> tests/drmsl
> move the test out of libudev test block
> 
> Signed-off-by: Jan Vesely 
> ---
> 
> Hi Emil,
> I know you send your R-b on the earlier version, but I thought the changes
> were big enough to send v2. I modeled it after you test splitting series.
> 
> jan
> 
>  .gitignore|   1 +
>  tests/Makefile.am |   5 +-
>  tests/drmsl.c | 172 
> ++
>  xf86drmSL.c   | 172 
> ++
>  4 files changed, 183 insertions(+), 167 deletions(-)
>  create mode 100644 tests/drmsl.c
> 
> diff --git a/.gitignore b/.gitignore
> index 06cc928..cb7128d 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -74,6 +74,7 @@ tdfx.kld
>  via.kld
>  tests/auth
>  tests/dristat
> +tests/drmsl
>  tests/drmstat
>  tests/getclient
>  tests/getstats
Hmm this reminds me that I missed out updating the .gitignore with my
series.

> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 10f54e3..ad70314 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -35,6 +35,9 @@ if HAVE_NOUVEAU
>  SUBDIRS += nouveau
>  endif
>  
> +TESTS = \
> + drmsl
> +
>  if HAVE_LIBUDEV
>  
>  check_LTLIBRARIES = libdrmtest.la
> @@ -52,7 +55,7 @@ XFAIL_TESTS =   \
>   auth\
>   lock
>  
> -TESTS =  \
> +TESTS += \
>   openclose   \
>   getversion  \
>   getclient   \
You will need the following hunk, otherwise drmsl will not end up in the
check target. Although when I think about it there isn't much value in
running this at make check time. I'll leave the decision up-to you.

--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -61,6 +61,7 @@ TESTS =   \
updatedraw  \
name_from_fd

+endif
+
 check_PROGRAMS += $(TESTS)

-endif


As before haven't explicitly checked the moved code so

Acked-by: Emil Velikov 

Thanks
Emil


[PATCH libdrm 2/3] tests/drmsl: Extract tests out of xf86drmSL.c

2015-03-24 Thread Jan Vesely
v2: merge tests creation and xf86drmSL cleanup
rename tests/drmsltest -> tests/drmsl
move the test out of libudev test block

Signed-off-by: Jan Vesely 
---

Hi Emil,
I know you send your R-b on the earlier version, but I thought the changes
were big enough to send v2. I modeled it after you test splitting series.

jan

 .gitignore|   1 +
 tests/Makefile.am |   5 +-
 tests/drmsl.c | 172 ++
 xf86drmSL.c   | 172 ++
 4 files changed, 183 insertions(+), 167 deletions(-)
 create mode 100644 tests/drmsl.c

diff --git a/.gitignore b/.gitignore
index 06cc928..cb7128d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@ tdfx.kld
 via.kld
 tests/auth
 tests/dristat
+tests/drmsl
 tests/drmstat
 tests/getclient
 tests/getstats
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 10f54e3..ad70314 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -35,6 +35,9 @@ if HAVE_NOUVEAU
 SUBDIRS += nouveau
 endif

+TESTS = \
+   drmsl
+
 if HAVE_LIBUDEV

 check_LTLIBRARIES = libdrmtest.la
@@ -52,7 +55,7 @@ XFAIL_TESTS = \
auth\
lock

-TESTS =\
+TESTS +=   \
openclose   \
getversion  \
getclient   \
diff --git a/tests/drmsl.c b/tests/drmsl.c
new file mode 100644
index 000..d0ac0ef
--- /dev/null
+++ b/tests/drmsl.c
@@ -0,0 +1,172 @@
+/* drmsl.c -- Skip list test
+ * Created: Mon May 10 09:28:13 1999 by faith at precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * 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
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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: Rickard E. (Rik) Faith 
+ *
+ * DESCRIPTION
+ *
+ * This file contains a straightforward skip list implementation.n
+ *
+ * FUTURE ENHANCEMENTS
+ *
+ * REFERENCES
+ *
+ * [Pugh90] William Pugh.  Skip Lists: A Probabilistic Alternative to
+ * Balanced Trees. CACM 33(6), June 1990, pp. 668-676.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include "xf86drm.h"
+
+static void print(void* list)
+{
+unsigned long key;
+void  *value;
+
+if (drmSLFirst(list, &key, &value)) {
+   do {
+   printf("key = %5lu, value = %p\n", key, value);
+   } while (drmSLNext(list, &key, &value));
+}
+}
+
+static double do_time(int size, int iter)
+{
+void   *list;
+inti, j;
+unsigned long  keys[100];
+unsigned long  previous;
+unsigned long  key;
+void   *value;
+struct timeval start, stop;
+double usec;
+void   *ranstate;
+
+list = drmSLCreate();
+ranstate = drmRandomCreate(12345);
+
+for (i = 0; i < size; i++) {
+   keys[i] = drmRandom(ranstate);
+   drmSLInsert(list, keys[i], NULL);
+}
+
+previous = 0;
+if (drmSLFirst(list, &key, &value)) {
+   do {
+   if (key <= previous) {
+   printf( "%lu !< %lu\n", previous, key);
+   }
+   previous = key;
+   } while (drmSLNext(list, &key, &value));
+}
+
+gettimeofday(&start, NULL);
+for (j = 0; j < iter; j++) {
+   for (i = 0; i < size; i++) {
+   if (drmSLLookup(list, keys[i], &value))
+   printf("Error %lu %d\n", keys[i], i);
+   }
+}
+gettimeofday(&stop, NULL);
+
+usec = (double)(stop.tv_sec * 100 + stop.tv_usec
+   - start.tv_sec * 100 - start.tv_usec) / (size * iter);
+
+printf("%0.2f microseconds for list length %d\n", usec, size);
+
+drmRandomDouble(ranstate);
+drmSLDestroy(list);
+
+return usec;
+}
+
+static void print_neighbors(void *list, unsigned