blob: 39ef7e30513f3ab5684eac58c279d67a9d9536c6 [file] [log] [blame]
Dan Willemsen09eb3b12015-09-16 14:34:17 -07001// Copyright 2015 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5#include <stdint.h>
6#include <stdio.h>
7
8#include "p.h"
9#include "libgo.h"
10
11// Tests libgo.so to export the following functions.
12// int8_t DidInitRun();
13// int8_t DidMainRun();
14// int32_t FromPkg();
Dan Willemsend2797482017-07-26 13:13:13 -070015// uint32_t Divu(uint32_t, uint32_t);
Dan Willemsen09eb3b12015-09-16 14:34:17 -070016int main(void) {
17 int8_t ran_init = DidInitRun();
18 if (!ran_init) {
19 fprintf(stderr, "ERROR: DidInitRun returned unexpected results: %d\n",
20 ran_init);
21 return 1;
22 }
23 int8_t ran_main = DidMainRun();
24 if (ran_main) {
25 fprintf(stderr, "ERROR: DidMainRun returned unexpected results: %d\n",
26 ran_main);
27 return 1;
28 }
29 int32_t from_pkg = FromPkg();
30 if (from_pkg != 1024) {
31 fprintf(stderr, "ERROR: FromPkg=%d, want %d\n", from_pkg, 1024);
32 return 1;
33 }
Dan Willemsend2797482017-07-26 13:13:13 -070034 uint32_t divu = Divu(2264, 31);
35 if (divu != 73) {
36 fprintf(stderr, "ERROR: Divu(2264, 31)=%d, want %d\n", divu, 73);
37 return 1;
38 }
Dan Willemsen09eb3b12015-09-16 14:34:17 -070039 // test.bash looks for "PASS" to ensure this program has reached the end.
40 printf("PASS\n");
41 return 0;
42}