]> git.saurik.com Git - apple/boot.git/blob - i386/tests/satest.c
9ae521ad61b89f33f8c09c864aafabd89995eec1
[apple/boot.git] / i386 / tests / satest.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* test standalone library */
26 #include <stdarg.h>
27
28 #define TEST_RESULT "The quick brown #5 fox did fine.\n"
29 #define TEST_FMT "The quick %s #%d fox did fine.\n"
30 #define TEST_ARGS "brown", 5
31
32 char error_buf[1024];
33 char *sa_rld_error_buf_addr = error_buf;
34 int sa_rld_error_buf_size = 1024;
35 char progname[] = "satest";
36
37 /*
38 * All printing of all messages goes through this function.
39 */
40 void
41 vprint(
42 const char *format,
43 va_list ap)
44 {
45 sa_rld_error_buf_size =- slvprintf(sa_rld_error_buf_addr,
46 sa_rld_error_buf_size,
47 format, ap);
48 }
49 /*
50 * Print the error message and set the 'error' indication.
51 */
52 void
53 error(
54 const char *format,
55 ...)
56 {
57 va_list ap;
58
59 // if(arch_multiple)
60 // print_architecture_banner();
61 va_start(ap, format);
62 // print("%s: ", progname);
63 vprint(format, ap);
64 // print("\n");
65 va_end(ap);
66 // errors = 1;
67 }
68
69 main()
70 {
71 char buf[1024];
72 int args[4], ret;
73
74 printf("Testing standalone library\n");
75 printf("The following two lines should be identical:\n");
76 sprintf(buf, TEST_FMT, TEST_ARGS);
77 printf(buf);
78 printf(TEST_RESULT);
79 printf("\nThe following two lines should be identical:\n");
80 error(TEST_FMT, TEST_ARGS);
81 printf(error_buf);
82 printf(TEST_RESULT);
83
84 printf("Comparing two strings:\n");
85 ret = strcmp("abra","cadabra");
86 printf("%d should not be 0.\n",ret);
87
88 printf("Comparing two strings:\n");
89 ret = strcmp("abra","abra");
90 printf("%d should be 0.\n",ret);
91
92 printf("Comparing two strings:\n");
93 ret = strncmp("abcdefghij","abcdef",6);
94 printf("%d should be 0.\n",ret);
95
96 printf("printf(\"Test: %% 12s\\n\",\"abb\");\n");
97 printf("Test: abb\n");
98 printf("Test: % 12s\n","abb");
99
100 printf("printf(\"Test: %%04d\\n\",77);\n");
101 printf("Test: 0077\n");
102 printf("Test: %04d\n",77);
103
104 printf("printf(\"Test: %% 2d\\n\",9);\n");
105 printf("Test: 9\n");
106 printf("Test: % 2d\n",9);
107
108 printf("printf(\"Test: %% 8d\\n\",-9);\n");
109 printf("Test: -9\n");
110 printf("Test: % 8d\n",-9);
111 }