2 * Copyright (C) 2015 Etnaviv Project
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Christian Gmeiner <christian.gmeiner@gmail.com>
32 #include "etnaviv_drmif.h"
34 static void test_avail()
36 struct etna_cmd_stream
*stream
;
38 printf("testing etna_cmd_stream_avail ... ");
41 stream
= etna_cmd_stream_new(NULL
, 0, NULL
, NULL
);
42 assert(stream
== NULL
);
44 stream
= etna_cmd_stream_new(NULL
, 4, NULL
, NULL
);
46 assert(etna_cmd_stream_avail(stream
) == 2);
47 etna_cmd_stream_del(stream
);
49 stream
= etna_cmd_stream_new(NULL
, 20, NULL
, NULL
);
51 assert(etna_cmd_stream_avail(stream
) == 18);
52 etna_cmd_stream_del(stream
);
54 /* odd number of 32 bit words */
55 stream
= etna_cmd_stream_new(NULL
, 1, NULL
, NULL
);
57 assert(etna_cmd_stream_avail(stream
) == 0);
58 etna_cmd_stream_del(stream
);
60 stream
= etna_cmd_stream_new(NULL
, 23, NULL
, NULL
);
62 assert(etna_cmd_stream_avail(stream
) == 22);
63 etna_cmd_stream_del(stream
);
68 static void test_emit()
70 struct etna_cmd_stream
*stream
;
72 printf("testing etna_cmd_stream_emit ... ");
74 stream
= etna_cmd_stream_new(NULL
, 6, NULL
, NULL
);
76 assert(etna_cmd_stream_avail(stream
) == 4);
78 etna_cmd_stream_emit(stream
, 0x1);
79 assert(etna_cmd_stream_avail(stream
) == 3);
81 etna_cmd_stream_emit(stream
, 0x2);
82 assert(etna_cmd_stream_avail(stream
) == 2);
84 etna_cmd_stream_emit(stream
, 0x3);
85 assert(etna_cmd_stream_avail(stream
) == 1);
87 etna_cmd_stream_del(stream
);
92 static void test_offset()
94 struct etna_cmd_stream
*stream
;
96 printf("testing etna_cmd_stream_offset ... ");
98 stream
= etna_cmd_stream_new(NULL
, 6, NULL
, NULL
);
99 assert(etna_cmd_stream_offset(stream
) == 0);
101 etna_cmd_stream_emit(stream
, 0x1);
102 assert(etna_cmd_stream_offset(stream
) == 1);
104 etna_cmd_stream_emit(stream
, 0x2);
105 assert(etna_cmd_stream_offset(stream
) == 2);
107 etna_cmd_stream_emit(stream
, 0x3);
108 etna_cmd_stream_emit(stream
, 0x4);
109 assert(etna_cmd_stream_offset(stream
) == 4);
111 etna_cmd_stream_del(stream
);
116 int main(int argc
, char *argv
[])