()
| 1655 | ], |
| 1656 | "as /stdlib.s /stdlib.o\nas /client.s /client.o\n\ |
| 1657 | ld /stdlib.o /client.o /hello\nrun /hello\nexit\n", |
| 1658 | 300_000_000, |
| 1659 | ); |
| 1660 | |
| 1661 | assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}"); |
| 1662 | assert!( |
| 1663 | !uart.contains("unhandled exception"), |
| 1664 | "the linked program faulted; uart={uart:?}" |
| 1665 | ); |
| 1666 | assert!( |
| 1667 | uart.contains("as: wrote /stdlib.o") && uart.contains("as: wrote /client.o"), |
| 1668 | "assembler did not emit both objects; uart={uart:?}" |
| 1669 | ); |
| 1670 | assert!( |
| 1671 | uart.contains("ld: wrote /hello"), |
| 1672 | "linker did not report success; uart={uart:?}" |
| 1673 | ); |
| 1674 | assert!( |
| 1675 | uart.contains("hello from stdlib!"), |
| 1676 | "stdlib puts/putc output missing; uart={uart:?}" |
| 1677 | ); |
| 1678 | assert!( |
| 1679 | uart.contains("[exit 42]"), |
| 1680 | "linked program did not exit 42 (relocations wrong?); uart={uart:?}" |
| 1681 | ); |
| 1682 | assert!( |
| 1683 | matches!(outcome, StepOutcome::Halted(0)), |
| 1684 | "shell did not survive and exit cleanly; outcome={outcome:?} uart={uart:?}" |
| 1685 | ); |
| 1686 | } |
| 1687 | |
| 1688 | // The whole in-VM toolchain in one run: cc, as, ld, then the loader. putc is no |
| 1689 | // longer a cc intrinsic, so it resolves at link time against stdlib.s. |
| 1690 | #[test] |
| 1691 | fn kernel_cc_compiles_and_runs() { |
| 1692 | let (outcome, uart) = run_tool_session( |
| 1693 | &["as", "cc", "ld"], |
| 1694 | &[ |
| 1695 | ("/prog.hll", user::CC_DEMO_HLL.as_bytes()), |
| 1696 | ("/stdlib.s", user::EXAMPLE_STDLIB_S.as_bytes()), |
| 1697 | ], |
| 1698 | "cc /prog.hll /prog.s\nas /prog.s /prog.o\nas /stdlib.s /stdlib.o\n\ |
| 1699 | ld /stdlib.o /prog.o /prog\nrun /prog\nexit\n", |
| 1700 | 300_000_000, |
| 1701 | ); |
| 1702 | |
| 1703 | assert!(!uart.contains("PANIC!"), "kernel panicked; uart={uart:?}"); |
| 1704 | assert!( |
| 1705 | !uart.contains("unhandled exception"), |
| 1706 | "the compiled program faulted; uart={uart:?}" |
| 1707 | ); |
| 1708 | assert!( |
| 1709 | uart.contains("cc: wrote /prog.s"), |
nothing calls this directly
no test coverage detected