Compile user code linked against the kernel stdlib. The kernel stdlib uses the "__kern_str_" string-label prefix so rodata labels never clash with user-code labels (which use "str_").
(user_src: &str)
| 437 | b: u8[2] = [] |
| 438 | a[0] = 65 |
| 439 | a[1] = 66 |
| 440 | b[0] = 65 |
| 441 | b[1] = 67 |
| 442 | a_ptr: u8* = &a[0] |
| 443 | b_ptr: u8* = &b[0] |
| 444 | result: i32 = mem.cmp(a_ptr, b_ptr, 2) |
| 445 | if result < 0 { |
| 446 | console.putchar(80) |
| 447 | console.putchar(65) |
| 448 | console.putchar(83) |
| 449 | console.putchar(83) |
| 450 | } |
| 451 | return 0 |
| 452 | } |
| 453 | "#, |
| 454 | ); |
| 455 | assert_eq!(uart, "PASS"); |
| 456 | assert_eq!(exit, Some(0)); |
| 457 | } |
| 458 | |
| 459 | // --- klog.hll --- |
| 460 | |
| 461 | #[test] |
| 462 | fn klog_ok_output() { |
| 463 | let (uart, exit) = run_with( |
| 464 | KLOG_SRC, |
| 465 | r#" |
| 466 | main: () -> i32 { |
| 467 | klog_ok("boot".ptr) |
| 468 | return 0 |
| 469 | } |
| 470 | "#, |
| 471 | ); |
| 472 | assert_eq!(uart, "[ OK ] boot\n"); |
| 473 | assert_eq!(exit, Some(0)); |
| 474 | } |
| 475 | |
| 476 | #[test] |
| 477 | fn klog_error_output() { |
| 478 | let (uart, exit) = run_with( |
| 479 | KLOG_SRC, |
| 480 | r#" |
| 481 | main: () -> i32 { |
| 482 | klog_error("fault".ptr) |
| 483 | return 0 |