main0.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // 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. #include <stdint.h>
  5. #include <stdio.h>
  6. #include "p.h"
  7. #include "libgo.h"
  8. // Tests libgo.so to export the following functions.
  9. // int8_t DidInitRun();
  10. // int8_t DidMainRun();
  11. // int32_t FromPkg();
  12. // uint32_t Divu(uint32_t, uint32_t);
  13. int main(void) {
  14. int8_t ran_init = DidInitRun();
  15. if (!ran_init) {
  16. fprintf(stderr, "ERROR: DidInitRun returned unexpected results: %d\n",
  17. ran_init);
  18. return 1;
  19. }
  20. int8_t ran_main = DidMainRun();
  21. if (ran_main) {
  22. fprintf(stderr, "ERROR: DidMainRun returned unexpected results: %d\n",
  23. ran_main);
  24. return 1;
  25. }
  26. int32_t from_pkg = FromPkg();
  27. if (from_pkg != 1024) {
  28. fprintf(stderr, "ERROR: FromPkg=%d, want %d\n", from_pkg, 1024);
  29. return 1;
  30. }
  31. uint32_t divu = Divu(2264, 31);
  32. if (divu != 73) {
  33. fprintf(stderr, "ERROR: Divu(2264, 31)=%d, want %d\n", divu, 73);
  34. return 1;
  35. }
  36. // test.bash looks for "PASS" to ensure this program has reached the end.
  37. printf("PASS\n");
  38. return 0;
  39. }