i8257: rename struct dma_regs to I8257Regs
[qemu/kevin.git] / tests / libqtest.c
blobfa314e1ee7bfea32cb2abd924050322a80c5bde5
1 /*
2 * QTest
4 * Copyright IBM, Corp. 2012
5 * Copyright Red Hat, Inc. 2012
6 * Copyright SUSE LINUX Products GmbH 2013
8 * Authors:
9 * Anthony Liguori <aliguori@us.ibm.com>
10 * Paolo Bonzini <pbonzini@redhat.com>
11 * Andreas Färber <afaerber@suse.de>
13 * This work is licensed under the terms of the GNU GPL, version 2 or later.
14 * See the COPYING file in the top-level directory.
17 #include "libqtest.h"
19 #include <glib.h>
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <sys/wait.h>
23 #include <sys/un.h>
24 #include <inttypes.h>
25 #include <errno.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
31 #include "qemu/compiler.h"
32 #include "qemu/osdep.h"
33 #include "qapi/qmp/json-parser.h"
34 #include "qapi/qmp/json-streamer.h"
35 #include "qapi/qmp/qjson.h"
37 #define MAX_IRQ 256
38 #define SOCKET_TIMEOUT 5
40 QTestState *global_qtest;
42 struct QTestState
44 int fd;
45 int qmp_fd;
46 bool irq_level[MAX_IRQ];
47 GString *rx;
48 pid_t qemu_pid; /* our child QEMU process */
51 static GHookList abrt_hooks;
52 static GList *qtest_instances;
53 static struct sigaction sigact_old;
55 #define g_assert_no_errno(ret) do { \
56 g_assert_cmpint(ret, !=, -1); \
57 } while (0)
59 static int init_socket(const char *socket_path)
61 struct sockaddr_un addr;
62 int sock;
63 int ret;
65 sock = socket(PF_UNIX, SOCK_STREAM, 0);
66 g_assert_no_errno(sock);
68 addr.sun_family = AF_UNIX;
69 snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path);
70 qemu_set_cloexec(sock);
72 do {
73 ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
74 } while (ret == -1 && errno == EINTR);
75 g_assert_no_errno(ret);
76 ret = listen(sock, 1);
77 g_assert_no_errno(ret);
79 return sock;
82 static int socket_accept(int sock)
84 struct sockaddr_un addr;
85 socklen_t addrlen;
86 int ret;
87 struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT,
88 .tv_usec = 0 };
90 setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout,
91 sizeof(timeout));
93 do {
94 addrlen = sizeof(addr);
95 ret = accept(sock, (struct sockaddr *)&addr, &addrlen);
96 } while (ret == -1 && errno == EINTR);
97 if (ret == -1) {
98 fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno));
100 close(sock);
102 return ret;
105 static void kill_qemu(QTestState *s)
107 if (s->qemu_pid != -1) {
108 kill(s->qemu_pid, SIGTERM);
109 waitpid(s->qemu_pid, NULL, 0);
113 static void kill_qemu_hook_func(void *s)
115 kill_qemu(s);
118 static void sigabrt_handler(int signo)
120 g_hook_list_invoke(&abrt_hooks, FALSE);
123 static void setup_sigabrt_handler(void)
125 struct sigaction sigact;
127 /* Catch SIGABRT to clean up on g_assert() failure */
128 sigact = (struct sigaction){
129 .sa_handler = sigabrt_handler,
130 .sa_flags = SA_RESETHAND,
132 sigemptyset(&sigact.sa_mask);
133 sigaction(SIGABRT, &sigact, &sigact_old);
136 static void cleanup_sigabrt_handler(void)
138 sigaction(SIGABRT, &sigact_old, NULL);
141 void qtest_add_abrt_handler(GHookFunc fn, const void *data)
143 GHook *hook;
145 /* Only install SIGABRT handler once */
146 if (!abrt_hooks.is_setup) {
147 g_hook_list_init(&abrt_hooks, sizeof(GHook));
148 setup_sigabrt_handler();
151 hook = g_hook_alloc(&abrt_hooks);
152 hook->func = fn;
153 hook->data = (void *)data;
155 g_hook_prepend(&abrt_hooks, hook);
158 QTestState *qtest_init(const char *extra_args)
160 QTestState *s;
161 int sock, qmpsock, i;
162 gchar *socket_path;
163 gchar *qmp_socket_path;
164 gchar *command;
165 const char *qemu_binary;
167 qemu_binary = getenv("QTEST_QEMU_BINARY");
168 g_assert(qemu_binary != NULL);
170 s = g_malloc(sizeof(*s));
172 socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
173 qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
175 sock = init_socket(socket_path);
176 qmpsock = init_socket(qmp_socket_path);
178 qtest_add_abrt_handler(kill_qemu_hook_func, s);
180 s->qemu_pid = fork();
181 if (s->qemu_pid == 0) {
182 setenv("QEMU_AUDIO_DRV", "none", true);
183 command = g_strdup_printf("exec %s "
184 "-qtest unix:%s,nowait "
185 "-qtest-log %s "
186 "-qmp unix:%s,nowait "
187 "-machine accel=qtest "
188 "-display none "
189 "%s", qemu_binary, socket_path,
190 getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
191 qmp_socket_path,
192 extra_args ?: "");
193 execlp("/bin/sh", "sh", "-c", command, NULL);
194 exit(1);
197 s->fd = socket_accept(sock);
198 if (s->fd >= 0) {
199 s->qmp_fd = socket_accept(qmpsock);
201 unlink(socket_path);
202 unlink(qmp_socket_path);
203 g_free(socket_path);
204 g_free(qmp_socket_path);
206 g_assert(s->fd >= 0 && s->qmp_fd >= 0);
208 s->rx = g_string_new("");
209 for (i = 0; i < MAX_IRQ; i++) {
210 s->irq_level[i] = false;
213 /* Read the QMP greeting and then do the handshake */
214 qtest_qmp_discard_response(s, "");
215 qtest_qmp_discard_response(s, "{ 'execute': 'qmp_capabilities' }");
217 if (getenv("QTEST_STOP")) {
218 kill(s->qemu_pid, SIGSTOP);
221 return s;
224 void qtest_quit(QTestState *s)
226 qtest_instances = g_list_remove(qtest_instances, s);
227 g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s));
229 /* Uninstall SIGABRT handler on last instance */
230 if (!qtest_instances) {
231 cleanup_sigabrt_handler();
234 kill_qemu(s);
235 close(s->fd);
236 close(s->qmp_fd);
237 g_string_free(s->rx, true);
238 g_free(s);
241 static void socket_send(int fd, const char *buf, size_t size)
243 size_t offset;
245 offset = 0;
246 while (offset < size) {
247 ssize_t len;
249 len = write(fd, buf + offset, size - offset);
250 if (len == -1 && errno == EINTR) {
251 continue;
254 g_assert_no_errno(len);
255 g_assert_cmpint(len, >, 0);
257 offset += len;
261 static void socket_sendf(int fd, const char *fmt, va_list ap)
263 gchar *str = g_strdup_vprintf(fmt, ap);
264 size_t size = strlen(str);
266 socket_send(fd, str, size);
267 g_free(str);
270 static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
272 va_list ap;
274 va_start(ap, fmt);
275 socket_sendf(s->fd, fmt, ap);
276 va_end(ap);
279 static GString *qtest_recv_line(QTestState *s)
281 GString *line;
282 size_t offset;
283 char *eol;
285 while ((eol = strchr(s->rx->str, '\n')) == NULL) {
286 ssize_t len;
287 char buffer[1024];
289 len = read(s->fd, buffer, sizeof(buffer));
290 if (len == -1 && errno == EINTR) {
291 continue;
294 if (len == -1 || len == 0) {
295 fprintf(stderr, "Broken pipe\n");
296 exit(1);
299 g_string_append_len(s->rx, buffer, len);
302 offset = eol - s->rx->str;
303 line = g_string_new_len(s->rx->str, offset);
304 g_string_erase(s->rx, 0, offset + 1);
306 return line;
309 static gchar **qtest_rsp(QTestState *s, int expected_args)
311 GString *line;
312 gchar **words;
313 int i;
315 redo:
316 line = qtest_recv_line(s);
317 words = g_strsplit(line->str, " ", 0);
318 g_string_free(line, TRUE);
320 if (strcmp(words[0], "IRQ") == 0) {
321 int irq;
323 g_assert(words[1] != NULL);
324 g_assert(words[2] != NULL);
326 irq = strtoul(words[2], NULL, 0);
327 g_assert_cmpint(irq, >=, 0);
328 g_assert_cmpint(irq, <, MAX_IRQ);
330 if (strcmp(words[1], "raise") == 0) {
331 s->irq_level[irq] = true;
332 } else {
333 s->irq_level[irq] = false;
336 g_strfreev(words);
337 goto redo;
340 g_assert(words[0] != NULL);
341 g_assert_cmpstr(words[0], ==, "OK");
343 if (expected_args) {
344 for (i = 0; i < expected_args; i++) {
345 g_assert(words[i] != NULL);
347 } else {
348 g_strfreev(words);
351 return words;
354 typedef struct {
355 JSONMessageParser parser;
356 QDict *response;
357 } QMPResponseParser;
359 static void qmp_response(JSONMessageParser *parser, GQueue *tokens)
361 QMPResponseParser *qmp = container_of(parser, QMPResponseParser, parser);
362 QObject *obj;
364 obj = json_parser_parse(tokens, NULL);
365 if (!obj) {
366 fprintf(stderr, "QMP JSON response parsing failed\n");
367 exit(1);
370 g_assert(qobject_type(obj) == QTYPE_QDICT);
371 g_assert(!qmp->response);
372 qmp->response = (QDict *)obj;
375 QDict *qmp_fd_receive(int fd)
377 QMPResponseParser qmp;
378 bool log = getenv("QTEST_LOG") != NULL;
380 qmp.response = NULL;
381 json_message_parser_init(&qmp.parser, qmp_response);
382 while (!qmp.response) {
383 ssize_t len;
384 char c;
386 len = read(fd, &c, 1);
387 if (len == -1 && errno == EINTR) {
388 continue;
391 if (len == -1 || len == 0) {
392 fprintf(stderr, "Broken pipe\n");
393 exit(1);
396 if (log) {
397 len = write(2, &c, 1);
399 json_message_parser_feed(&qmp.parser, &c, 1);
401 json_message_parser_destroy(&qmp.parser);
403 return qmp.response;
406 QDict *qtest_qmp_receive(QTestState *s)
408 return qmp_fd_receive(s->qmp_fd);
412 * Allow users to send a message without waiting for the reply,
413 * in the case that they choose to discard all replies up until
414 * a particular EVENT is received.
416 void qmp_fd_sendv(int fd, const char *fmt, va_list ap)
418 va_list ap_copy;
419 QObject *qobj;
421 /* Going through qobject ensures we escape strings properly.
422 * This seemingly unnecessary copy is required in case va_list
423 * is an array type.
425 va_copy(ap_copy, ap);
426 qobj = qobject_from_jsonv(fmt, &ap_copy);
427 va_end(ap_copy);
429 /* No need to send anything for an empty QObject. */
430 if (qobj) {
431 int log = getenv("QTEST_LOG") != NULL;
432 QString *qstr = qobject_to_json(qobj);
433 const char *str = qstring_get_str(qstr);
434 size_t size = qstring_get_length(qstr);
436 if (log) {
437 fprintf(stderr, "%s", str);
439 /* Send QMP request */
440 socket_send(fd, str, size);
442 QDECREF(qstr);
443 qobject_decref(qobj);
447 void qtest_async_qmpv(QTestState *s, const char *fmt, va_list ap)
449 qmp_fd_sendv(s->qmp_fd, fmt, ap);
452 QDict *qmp_fdv(int fd, const char *fmt, va_list ap)
454 qmp_fd_sendv(fd, fmt, ap);
456 return qmp_fd_receive(fd);
459 QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
461 qtest_async_qmpv(s, fmt, ap);
463 /* Receive reply */
464 return qtest_qmp_receive(s);
467 QDict *qmp_fd(int fd, const char *fmt, ...)
469 va_list ap;
470 QDict *response;
472 va_start(ap, fmt);
473 response = qmp_fdv(fd, fmt, ap);
474 va_end(ap);
475 return response;
478 void qmp_fd_send(int fd, const char *fmt, ...)
480 va_list ap;
482 va_start(ap, fmt);
483 qmp_fd_sendv(fd, fmt, ap);
484 va_end(ap);
487 QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
489 va_list ap;
490 QDict *response;
492 va_start(ap, fmt);
493 response = qtest_qmpv(s, fmt, ap);
494 va_end(ap);
495 return response;
498 void qtest_async_qmp(QTestState *s, const char *fmt, ...)
500 va_list ap;
502 va_start(ap, fmt);
503 qtest_async_qmpv(s, fmt, ap);
504 va_end(ap);
507 void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap)
509 QDict *response = qtest_qmpv(s, fmt, ap);
510 QDECREF(response);
513 void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
515 va_list ap;
516 QDict *response;
518 va_start(ap, fmt);
519 response = qtest_qmpv(s, fmt, ap);
520 va_end(ap);
521 QDECREF(response);
524 void qtest_qmp_eventwait(QTestState *s, const char *event)
526 QDict *response;
528 for (;;) {
529 response = qtest_qmp_receive(s);
530 if ((qdict_haskey(response, "event")) &&
531 (strcmp(qdict_get_str(response, "event"), event) == 0)) {
532 QDECREF(response);
533 break;
535 QDECREF(response);
539 char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
541 char *cmd;
542 QDict *resp;
543 char *ret;
545 cmd = g_strdup_vprintf(fmt, ap);
546 resp = qtest_qmp(s, "{'execute': 'human-monitor-command',"
547 " 'arguments': {'command-line': %s}}",
548 cmd);
549 ret = g_strdup(qdict_get_try_str(resp, "return"));
550 g_assert(ret);
551 QDECREF(resp);
552 g_free(cmd);
553 return ret;
556 char *qtest_hmp(QTestState *s, const char *fmt, ...)
558 va_list ap;
559 char *ret;
561 va_start(ap, fmt);
562 ret = qtest_hmpv(s, fmt, ap);
563 va_end(ap);
564 return ret;
567 const char *qtest_get_arch(void)
569 const char *qemu = getenv("QTEST_QEMU_BINARY");
570 g_assert(qemu != NULL);
571 const char *end = strrchr(qemu, '/');
573 return end + strlen("/qemu-system-");
576 bool qtest_get_irq(QTestState *s, int num)
578 /* dummy operation in order to make sure irq is up to date */
579 qtest_inb(s, 0);
581 return s->irq_level[num];
584 static int64_t qtest_clock_rsp(QTestState *s)
586 gchar **words;
587 int64_t clock;
588 words = qtest_rsp(s, 2);
589 clock = g_ascii_strtoll(words[1], NULL, 0);
590 g_strfreev(words);
591 return clock;
594 int64_t qtest_clock_step_next(QTestState *s)
596 qtest_sendf(s, "clock_step\n");
597 return qtest_clock_rsp(s);
600 int64_t qtest_clock_step(QTestState *s, int64_t step)
602 qtest_sendf(s, "clock_step %"PRIi64"\n", step);
603 return qtest_clock_rsp(s);
606 int64_t qtest_clock_set(QTestState *s, int64_t val)
608 qtest_sendf(s, "clock_set %"PRIi64"\n", val);
609 return qtest_clock_rsp(s);
612 void qtest_irq_intercept_out(QTestState *s, const char *qom_path)
614 qtest_sendf(s, "irq_intercept_out %s\n", qom_path);
615 qtest_rsp(s, 0);
618 void qtest_irq_intercept_in(QTestState *s, const char *qom_path)
620 qtest_sendf(s, "irq_intercept_in %s\n", qom_path);
621 qtest_rsp(s, 0);
624 static void qtest_out(QTestState *s, const char *cmd, uint16_t addr, uint32_t value)
626 qtest_sendf(s, "%s 0x%x 0x%x\n", cmd, addr, value);
627 qtest_rsp(s, 0);
630 void qtest_outb(QTestState *s, uint16_t addr, uint8_t value)
632 qtest_out(s, "outb", addr, value);
635 void qtest_outw(QTestState *s, uint16_t addr, uint16_t value)
637 qtest_out(s, "outw", addr, value);
640 void qtest_outl(QTestState *s, uint16_t addr, uint32_t value)
642 qtest_out(s, "outl", addr, value);
645 static uint32_t qtest_in(QTestState *s, const char *cmd, uint16_t addr)
647 gchar **args;
648 uint32_t value;
650 qtest_sendf(s, "%s 0x%x\n", cmd, addr);
651 args = qtest_rsp(s, 2);
652 value = strtoul(args[1], NULL, 0);
653 g_strfreev(args);
655 return value;
658 uint8_t qtest_inb(QTestState *s, uint16_t addr)
660 return qtest_in(s, "inb", addr);
663 uint16_t qtest_inw(QTestState *s, uint16_t addr)
665 return qtest_in(s, "inw", addr);
668 uint32_t qtest_inl(QTestState *s, uint16_t addr)
670 return qtest_in(s, "inl", addr);
673 static void qtest_write(QTestState *s, const char *cmd, uint64_t addr,
674 uint64_t value)
676 qtest_sendf(s, "%s 0x%" PRIx64 " 0x%" PRIx64 "\n", cmd, addr, value);
677 qtest_rsp(s, 0);
680 void qtest_writeb(QTestState *s, uint64_t addr, uint8_t value)
682 qtest_write(s, "writeb", addr, value);
685 void qtest_writew(QTestState *s, uint64_t addr, uint16_t value)
687 qtest_write(s, "writew", addr, value);
690 void qtest_writel(QTestState *s, uint64_t addr, uint32_t value)
692 qtest_write(s, "writel", addr, value);
695 void qtest_writeq(QTestState *s, uint64_t addr, uint64_t value)
697 qtest_write(s, "writeq", addr, value);
700 static uint64_t qtest_read(QTestState *s, const char *cmd, uint64_t addr)
702 gchar **args;
703 uint64_t value;
705 qtest_sendf(s, "%s 0x%" PRIx64 "\n", cmd, addr);
706 args = qtest_rsp(s, 2);
707 value = strtoull(args[1], NULL, 0);
708 g_strfreev(args);
710 return value;
713 uint8_t qtest_readb(QTestState *s, uint64_t addr)
715 return qtest_read(s, "readb", addr);
718 uint16_t qtest_readw(QTestState *s, uint64_t addr)
720 return qtest_read(s, "readw", addr);
723 uint32_t qtest_readl(QTestState *s, uint64_t addr)
725 return qtest_read(s, "readl", addr);
728 uint64_t qtest_readq(QTestState *s, uint64_t addr)
730 return qtest_read(s, "readq", addr);
733 static int hex2nib(char ch)
735 if (ch >= '0' && ch <= '9') {
736 return ch - '0';
737 } else if (ch >= 'a' && ch <= 'f') {
738 return 10 + (ch - 'a');
739 } else if (ch >= 'A' && ch <= 'F') {
740 return 10 + (ch - 'a');
741 } else {
742 return -1;
746 void qtest_memread(QTestState *s, uint64_t addr, void *data, size_t size)
748 uint8_t *ptr = data;
749 gchar **args;
750 size_t i;
752 qtest_sendf(s, "read 0x%" PRIx64 " 0x%zx\n", addr, size);
753 args = qtest_rsp(s, 2);
755 for (i = 0; i < size; i++) {
756 ptr[i] = hex2nib(args[1][2 + (i * 2)]) << 4;
757 ptr[i] |= hex2nib(args[1][2 + (i * 2) + 1]);
760 g_strfreev(args);
763 void qtest_add_func(const char *str, void (*fn)(void))
765 gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
766 g_test_add_func(path, fn);
767 g_free(path);
770 void qtest_add_data_func(const char *str, const void *data,
771 void (*fn)(const void *))
773 gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
774 g_test_add_data_func(path, data, fn);
775 g_free(path);
778 void qtest_bufwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
780 gchar *bdata;
782 bdata = g_base64_encode(data, size);
783 qtest_sendf(s, "b64write 0x%" PRIx64 " 0x%zx ", addr, size);
784 socket_send(s->fd, bdata, strlen(bdata));
785 socket_send(s->fd, "\n", 1);
786 qtest_rsp(s, 0);
787 g_free(bdata);
790 void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size)
792 gchar **args;
793 size_t len;
795 qtest_sendf(s, "b64read 0x%" PRIx64 " 0x%zx\n", addr, size);
796 args = qtest_rsp(s, 2);
798 g_base64_decode_inplace(args[1], &len);
799 if (size != len) {
800 fprintf(stderr, "bufread: asked for %zu bytes but decoded %zu\n",
801 size, len);
802 len = MIN(len, size);
805 memcpy(data, args[1], len);
806 g_strfreev(args);
809 void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
811 const uint8_t *ptr = data;
812 size_t i;
813 char *enc = g_malloc(2 * size + 1);
815 for (i = 0; i < size; i++) {
816 sprintf(&enc[i * 2], "%02x", ptr[i]);
819 qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x%s\n", addr, size, enc);
820 qtest_rsp(s, 0);
821 g_free(enc);
824 void qtest_memset(QTestState *s, uint64_t addr, uint8_t pattern, size_t size)
826 qtest_sendf(s, "memset 0x%" PRIx64 " 0x%zx 0x%02x\n", addr, size, pattern);
827 qtest_rsp(s, 0);
830 QDict *qmp(const char *fmt, ...)
832 va_list ap;
833 QDict *response;
835 va_start(ap, fmt);
836 response = qtest_qmpv(global_qtest, fmt, ap);
837 va_end(ap);
838 return response;
841 void qmp_async(const char *fmt, ...)
843 va_list ap;
845 va_start(ap, fmt);
846 qtest_async_qmpv(global_qtest, fmt, ap);
847 va_end(ap);
850 void qmp_discard_response(const char *fmt, ...)
852 va_list ap;
854 va_start(ap, fmt);
855 qtest_qmpv_discard_response(global_qtest, fmt, ap);
856 va_end(ap);
858 char *hmp(const char *fmt, ...)
860 va_list ap;
861 char *ret;
863 va_start(ap, fmt);
864 ret = qtest_hmpv(global_qtest, fmt, ap);
865 va_end(ap);
866 return ret;
869 bool qtest_big_endian(void)
871 const char *arch = qtest_get_arch();
872 int i;
874 static const struct {
875 const char *arch;
876 bool big_endian;
877 } endianness[] = {
878 { "aarch64", false },
879 { "alpha", false },
880 { "arm", false },
881 { "cris", false },
882 { "i386", false },
883 { "lm32", true },
884 { "m68k", true },
885 { "microblaze", true },
886 { "microblazeel", false },
887 { "mips", true },
888 { "mips64", true },
889 { "mips64el", false },
890 { "mipsel", false },
891 { "moxie", true },
892 { "or32", true },
893 { "ppc", true },
894 { "ppc64", true },
895 { "ppcemb", true },
896 { "s390x", true },
897 { "sh4", false },
898 { "sh4eb", true },
899 { "sparc", true },
900 { "sparc64", true },
901 { "unicore32", false },
902 { "x86_64", false },
903 { "xtensa", false },
904 { "xtensaeb", true },
908 for (i = 0; endianness[i].arch; i++) {
909 if (strcmp(endianness[i].arch, arch) == 0) {
910 return endianness[i].big_endian;
914 return false;