aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt2008-04-29 15:45:43 -0500
committerEric Anholt2008-04-29 15:45:43 -0500
commit3148c1636408cc422ab83c149a8963916dd376b0 (patch)
treea83587b203c50cfca6f870bb07031add3879d962
parentdabd056bf34b389585b618cf03a297877505f06b (diff)
downloadexternal-libdrm-3148c1636408cc422ab83c149a8963916dd376b0.tar.gz
external-libdrm-3148c1636408cc422ab83c149a8963916dd376b0.tar.xz
external-libdrm-3148c1636408cc422ab83c149a8963916dd376b0.zip
Move mmfs tests over to be drm tests.
-rw-r--r--.gitignore6
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/mm_basic.c (renamed from tests/mmfs_basic.c)33
-rw-r--r--tests/mm_mmap.c (renamed from tests/mmfs_mmap.c)40
-rw-r--r--tests/mm_readwrite.c (renamed from tests/mmfs_readwrite.c)34
5 files changed, 53 insertions, 66 deletions
diff --git a/.gitignore b/.gitignore
index 4d89a3cb..89172e6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,9 +58,9 @@ tests/getclient
58tests/getstats 58tests/getstats
59tests/getversion 59tests/getversion
60tests/lock 60tests/lock
61tests/mmfs_basic 61tests/mm_basic
62tests/mmfs_mmap 62tests/mm_mmap
63tests/mmfs_readwrite 63tests/mm_readwrite
64tests/openclose 64tests/openclose
65tests/setversion 65tests/setversion
66tests/updatedraw 66tests/updatedraw
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 67cb034d..f997e26e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,9 +23,9 @@ TESTS = auth \
23 lock \ 23 lock \
24 setversion \ 24 setversion \
25 updatedraw \ 25 updatedraw \
26 mmfs_basic \ 26 mm_basic \
27 mmfs_readwrite \ 27 mm_readwrite \
28 mmfs_mmap 28 mm_mmap
29 29
30EXTRA_PROGRAMS = $(TESTS) 30EXTRA_PROGRAMS = $(TESTS)
31CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES) 31CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES)
diff --git a/tests/mmfs_basic.c b/tests/mm_basic.c
index c6975b0b..94240ee1 100644
--- a/tests/mmfs_basic.c
+++ b/tests/mm_basic.c
@@ -33,30 +33,18 @@
33#include <inttypes.h> 33#include <inttypes.h>
34#include <errno.h> 34#include <errno.h>
35#include <sys/stat.h> 35#include <sys/stat.h>
36#include "mmfs.h" 36#include "drm.h"
37 37
38static void 38static void
39test_bad_unref(int fd) 39test_bad_unref(int fd)
40{ 40{
41 struct mmfs_unreference_args unref; 41 struct drm_mm_unreference_args unref;
42 int ret; 42 int ret;
43 43
44 printf("Testing error return on bad unreference ioctl.\n"); 44 printf("Testing error return on bad unreference ioctl.\n");
45 45
46 unref.handle = 0x10101010; 46 unref.handle = 0x10101010;
47 ret = ioctl(fd, MMFS_IOCTL_UNREFERENCE, &unref); 47 ret = ioctl(fd, DRM_IOCTL_MM_UNREFERENCE, &unref);
48
49 assert(ret == -1 && errno == EINVAL);
50}
51
52static void
53test_bad_ioctl(int fd)
54{
55 int ret;
56
57 printf("Testing error return on bad ioctl.\n");
58
59 ret = ioctl(fd, _IO(MMFS_IOCTL_BASE, 0xf0), 0);
60 48
61 assert(ret == -1 && errno == EINVAL); 49 assert(ret == -1 && errno == EINVAL);
62} 50}
@@ -64,32 +52,32 @@ test_bad_ioctl(int fd)
64static void 52static void
65test_alloc_unref(int fd) 53test_alloc_unref(int fd)
66{ 54{
67 struct mmfs_alloc_args alloc; 55 struct drm_mm_alloc_args alloc;
68 struct mmfs_unreference_args unref; 56 struct drm_mm_unreference_args unref;
69 int ret; 57 int ret;
70 58
71 printf("Testing allocating and unreferencing an object.\n"); 59 printf("Testing allocating and unreferencing an object.\n");
72 60
73 memset(&alloc, 0, sizeof(alloc)); 61 memset(&alloc, 0, sizeof(alloc));
74 alloc.size = 16 * 1024; 62 alloc.size = 16 * 1024;
75 ret = ioctl(fd, MMFS_IOCTL_ALLOC, &alloc); 63 ret = ioctl(fd, DRM_IOCTL_MM_ALLOC, &alloc);
76 assert(ret == 0); 64 assert(ret == 0);
77 65
78 unref.handle = alloc.handle; 66 unref.handle = alloc.handle;
79 ret = ioctl(fd, MMFS_IOCTL_UNREFERENCE, &unref); 67 ret = ioctl(fd, DRM_IOCTL_MM_UNREFERENCE, &unref);
80} 68}
81 69
82static void 70static void
83test_alloc_close(int fd) 71test_alloc_close(int fd)
84{ 72{
85 struct mmfs_alloc_args alloc; 73 struct drm_mm_alloc_args alloc;
86 int ret; 74 int ret;
87 75
88 printf("Testing closing with an object allocated.\n"); 76 printf("Testing closing with an object allocated.\n");
89 77
90 memset(&alloc, 0, sizeof(alloc)); 78 memset(&alloc, 0, sizeof(alloc));
91 alloc.size = 16 * 1024; 79 alloc.size = 16 * 1024;
92 ret = ioctl(fd, MMFS_IOCTL_ALLOC, &alloc); 80 ret = ioctl(fd, DRM_IOCTL_MM_ALLOC, &alloc);
93 assert(ret == 0); 81 assert(ret == 0);
94 82
95 close(fd); 83 close(fd);
@@ -99,9 +87,8 @@ int main(int argc, char **argv)
99{ 87{
100 int fd; 88 int fd;
101 89
102 fd = open_mmfs_device(); 90 fd = drm_open_any();
103 91
104 test_bad_ioctl(fd);
105 test_bad_unref(fd); 92 test_bad_unref(fd);
106 test_alloc_unref(fd); 93 test_alloc_unref(fd);
107 test_alloc_close(fd); 94 test_alloc_close(fd);
diff --git a/tests/mmfs_mmap.c b/tests/mm_mmap.c
index 3cb6a853..e5c4538a 100644
--- a/tests/mmfs_mmap.c
+++ b/tests/mm_mmap.c
@@ -33,13 +33,13 @@
33#include <inttypes.h> 33#include <inttypes.h>
34#include <errno.h> 34#include <errno.h>
35#include <sys/stat.h> 35#include <sys/stat.h>
36#include "mmfs.h" 36#include "drm.h"
37 37
38#define MMFS_BUFFER_SIZE 16384 38#define OBJECT_SIZE 16384
39 39
40int do_read(int fd, int handle, void *buf, int offset, int size) 40int do_read(int fd, int handle, void *buf, int offset, int size)
41{ 41{
42 struct mmfs_pread_args read; 42 struct drm_mm_pread_args read;
43 43
44 /* Ensure that we don't have any convenient data in buf in case 44 /* Ensure that we don't have any convenient data in buf in case
45 * we fail. 45 * we fail.
@@ -52,12 +52,12 @@ int do_read(int fd, int handle, void *buf, int offset, int size)
52 read.size = size; 52 read.size = size;
53 read.offset = offset; 53 read.offset = offset;
54 54
55 return ioctl(fd, MMFS_IOCTL_PREAD, &read); 55 return ioctl(fd, DRM_IOCTL_MM_PREAD, &read);
56} 56}
57 57
58int do_write(int fd, int handle, void *buf, int offset, int size) 58int do_write(int fd, int handle, void *buf, int offset, int size)
59{ 59{
60 struct mmfs_pwrite_args write; 60 struct drm_mm_pwrite_args write;
61 61
62 memset(&write, 0, sizeof(write)); 62 memset(&write, 0, sizeof(write));
63 write.handle = handle; 63 write.handle = handle;
@@ -65,41 +65,41 @@ int do_write(int fd, int handle, void *buf, int offset, int size)
65 write.size = size; 65 write.size = size;
66 write.offset = offset; 66 write.offset = offset;
67 67
68 return ioctl(fd, MMFS_IOCTL_PWRITE, &write); 68 return ioctl(fd, DRM_IOCTL_MM_PWRITE, &write);
69} 69}
70 70
71int main(int argc, char **argv) 71int main(int argc, char **argv)
72{ 72{
73 int fd; 73 int fd;
74 struct mmfs_alloc_args alloc; 74 struct drm_mm_alloc_args alloc;
75 struct mmfs_mmap_args mmap; 75 struct drm_mm_mmap_args mmap;
76 struct mmfs_unreference_args unref; 76 struct drm_mm_unreference_args unref;
77 uint8_t expected[MMFS_BUFFER_SIZE]; 77 uint8_t expected[OBJECT_SIZE];
78 uint8_t buf[MMFS_BUFFER_SIZE]; 78 uint8_t buf[OBJECT_SIZE];
79 int ret; 79 int ret;
80 int handle; 80 int handle;
81 81
82 fd = open_mmfs_device(); 82 fd = drm_open_any();
83 83
84 memset(&mmap, 0, sizeof(mmap)); 84 memset(&mmap, 0, sizeof(mmap));
85 mmap.handle = 0x10101010; 85 mmap.handle = 0x10101010;
86 mmap.offset = 0; 86 mmap.offset = 0;
87 mmap.size = 4096; 87 mmap.size = 4096;
88 printf("Testing mmaping of bad object.\n"); 88 printf("Testing mmaping of bad object.\n");
89 ret = ioctl(fd, MMFS_IOCTL_MMAP, &mmap); 89 ret = ioctl(fd, DRM_IOCTL_MM_MMAP, &mmap);
90 assert(ret == -1 && errno == EINVAL); 90 assert(ret == -1 && errno == EINVAL);
91 91
92 memset(&alloc, 0, sizeof(alloc)); 92 memset(&alloc, 0, sizeof(alloc));
93 alloc.size = MMFS_BUFFER_SIZE; 93 alloc.size = OBJECT_SIZE;
94 ret = ioctl(fd, MMFS_IOCTL_ALLOC, &alloc); 94 ret = ioctl(fd, DRM_IOCTL_MM_ALLOC, &alloc);
95 assert(ret == 0); 95 assert(ret == 0);
96 handle = alloc.handle; 96 handle = alloc.handle;
97 97
98 printf("Testing mmaping of newly allocated object.\n"); 98 printf("Testing mmaping of newly allocated object.\n");
99 mmap.handle = handle; 99 mmap.handle = handle;
100 mmap.offset = 0; 100 mmap.offset = 0;
101 mmap.size = MMFS_BUFFER_SIZE; 101 mmap.size = OBJECT_SIZE;
102 ret = ioctl(fd, MMFS_IOCTL_MMAP, &mmap); 102 ret = ioctl(fd, DRM_IOCTL_MM_MMAP, &mmap);
103 assert(ret == 0); 103 assert(ret == 0);
104 104
105 printf("Testing contents of newly allocated object.\n"); 105 printf("Testing contents of newly allocated object.\n");
@@ -110,18 +110,18 @@ int main(int argc, char **argv)
110 memset(buf, 0, sizeof(buf)); 110 memset(buf, 0, sizeof(buf));
111 memset(buf + 1024, 0x01, 1024); 111 memset(buf + 1024, 0x01, 1024);
112 memset(expected + 1024, 0x01, 1024); 112 memset(expected + 1024, 0x01, 1024);
113 ret = do_write(fd, handle, buf, 0, MMFS_BUFFER_SIZE); 113 ret = do_write(fd, handle, buf, 0, OBJECT_SIZE);
114 assert(ret == 0); 114 assert(ret == 0);
115 assert(memcmp(buf, mmap.addr, sizeof(buf)) == 0); 115 assert(memcmp(buf, mmap.addr, sizeof(buf)) == 0);
116 116
117 printf("Testing that mapping stays after unreference\n"); 117 printf("Testing that mapping stays after unreference\n");
118 unref.handle = handle; 118 unref.handle = handle;
119 ret = ioctl(fd, MMFS_IOCTL_UNREFERENCE, &unref); 119 ret = ioctl(fd, DRM_IOCTL_MM_UNREFERENCE, &unref);
120 assert(ret == 0); 120 assert(ret == 0);
121 assert(memcmp(buf, mmap.addr, sizeof(buf)) == 0); 121 assert(memcmp(buf, mmap.addr, sizeof(buf)) == 0);
122 122
123 printf("Testing unmapping\n"); 123 printf("Testing unmapping\n");
124 munmap(mmap.addr, MMFS_BUFFER_SIZE); 124 munmap(mmap.addr, OBJECT_SIZE);
125 125
126 close(fd); 126 close(fd);
127 127
diff --git a/tests/mmfs_readwrite.c b/tests/mm_readwrite.c
index 09d1967d..a778231a 100644
--- a/tests/mmfs_readwrite.c
+++ b/tests/mm_readwrite.c
@@ -33,13 +33,13 @@
33#include <inttypes.h> 33#include <inttypes.h>
34#include <errno.h> 34#include <errno.h>
35#include <sys/stat.h> 35#include <sys/stat.h>
36#include "mmfs.h" 36#include "drm.h"
37 37
38#define MMFS_BUFFER_SIZE 16384 38#define OBJECT_SIZE 16384
39 39
40int do_read(int fd, int handle, void *buf, int offset, int size) 40int do_read(int fd, int handle, void *buf, int offset, int size)
41{ 41{
42 struct mmfs_pread_args read; 42 struct drm_mm_pread_args read;
43 43
44 /* Ensure that we don't have any convenient data in buf in case 44 /* Ensure that we don't have any convenient data in buf in case
45 * we fail. 45 * we fail.
@@ -52,12 +52,12 @@ int do_read(int fd, int handle, void *buf, int offset, int size)
52 read.size = size; 52 read.size = size;
53 read.offset = offset; 53 read.offset = offset;
54 54
55 return ioctl(fd, MMFS_IOCTL_PREAD, &read); 55 return ioctl(fd, DRM_IOCTL_MM_PREAD, &read);
56} 56}
57 57
58int do_write(int fd, int handle, void *buf, int offset, int size) 58int do_write(int fd, int handle, void *buf, int offset, int size)
59{ 59{
60 struct mmfs_pwrite_args write; 60 struct drm_mm_pwrite_args write;
61 61
62 memset(&write, 0, sizeof(write)); 62 memset(&write, 0, sizeof(write));
63 write.handle = handle; 63 write.handle = handle;
@@ -65,43 +65,43 @@ int do_write(int fd, int handle, void *buf, int offset, int size)
65 write.size = size; 65 write.size = size;
66 write.offset = offset; 66 write.offset = offset;
67 67
68 return ioctl(fd, MMFS_IOCTL_PWRITE, &write); 68 return ioctl(fd, DRM_IOCTL_MM_PWRITE, &write);
69} 69}
70 70
71int main(int argc, char **argv) 71int main(int argc, char **argv)
72{ 72{
73 int fd; 73 int fd;
74 struct mmfs_alloc_args alloc; 74 struct drm_mm_alloc_args alloc;
75 uint8_t expected[MMFS_BUFFER_SIZE]; 75 uint8_t expected[OBJECT_SIZE];
76 uint8_t buf[MMFS_BUFFER_SIZE]; 76 uint8_t buf[OBJECT_SIZE];
77 int ret; 77 int ret;
78 int handle; 78 int handle;
79 79
80 fd = open_mmfs_device(); 80 fd = drm_open_any();
81 81
82 memset(&alloc, 0, sizeof(alloc)); 82 memset(&alloc, 0, sizeof(alloc));
83 alloc.size = MMFS_BUFFER_SIZE; 83 alloc.size = OBJECT_SIZE;
84 ret = ioctl(fd, MMFS_IOCTL_ALLOC, &alloc); 84 ret = ioctl(fd, DRM_IOCTL_MM_ALLOC, &alloc);
85 assert(ret == 0); 85 assert(ret == 0);
86 handle = alloc.handle; 86 handle = alloc.handle;
87 87
88 printf("Testing contents of newly allocated object.\n"); 88 printf("Testing contents of newly allocated object.\n");
89 ret = do_read(fd, handle, buf, 0, MMFS_BUFFER_SIZE); 89 ret = do_read(fd, handle, buf, 0, OBJECT_SIZE);
90 assert(ret == 0); 90 assert(ret == 0);
91 memset(&expected, 0, sizeof(expected)); 91 memset(&expected, 0, sizeof(expected));
92 assert(memcmp(expected, buf, sizeof(expected)) == 0); 92 assert(memcmp(expected, buf, sizeof(expected)) == 0);
93 93
94 printf("Testing read beyond end of buffer.\n"); 94 printf("Testing read beyond end of buffer.\n");
95 ret = do_read(fd, handle, buf, MMFS_BUFFER_SIZE / 2, MMFS_BUFFER_SIZE); 95 ret = do_read(fd, handle, buf, OBJECT_SIZE / 2, OBJECT_SIZE);
96 assert(ret == -1 && errno == EINVAL); 96 assert(ret == -1 && errno == EINVAL);
97 97
98 printf("Testing full write of buffer\n"); 98 printf("Testing full write of buffer\n");
99 memset(buf, 0, sizeof(buf)); 99 memset(buf, 0, sizeof(buf));
100 memset(buf + 1024, 0x01, 1024); 100 memset(buf + 1024, 0x01, 1024);
101 memset(expected + 1024, 0x01, 1024); 101 memset(expected + 1024, 0x01, 1024);
102 ret = do_write(fd, handle, buf, 0, MMFS_BUFFER_SIZE); 102 ret = do_write(fd, handle, buf, 0, OBJECT_SIZE);
103 assert(ret == 0); 103 assert(ret == 0);
104 ret = do_read(fd, handle, buf, 0, MMFS_BUFFER_SIZE); 104 ret = do_read(fd, handle, buf, 0, OBJECT_SIZE);
105 assert(ret == 0); 105 assert(ret == 0);
106 assert(memcmp(buf, expected, sizeof(buf)) == 0); 106 assert(memcmp(buf, expected, sizeof(buf)) == 0);
107 107
@@ -110,7 +110,7 @@ int main(int argc, char **argv)
110 memset(expected + 4096, 0x02, 1024); 110 memset(expected + 4096, 0x02, 1024);
111 ret = do_write(fd, handle, buf + 4096, 4096, 1024); 111 ret = do_write(fd, handle, buf + 4096, 4096, 1024);
112 assert(ret == 0); 112 assert(ret == 0);
113 ret = do_read(fd, handle, buf, 0, MMFS_BUFFER_SIZE); 113 ret = do_read(fd, handle, buf, 0, OBJECT_SIZE);
114 assert(ret == 0); 114 assert(ret == 0);
115 assert(memcmp(buf, expected, sizeof(buf)) == 0); 115 assert(memcmp(buf, expected, sizeof(buf)) == 0);
116 116