├── api ├── net │ ├── http │ │ └── parse.hpp │ ├── inet4 │ ├── inet │ └── openssl │ │ └── init.hpp ├── ide ├── posix │ └── stddef.h ├── async ├── config ├── autoconf ├── likely ├── detail │ └── os.hpp ├── pmr ├── kernel │ └── diag.hpp └── fuzz │ ├── macfuzzy.hpp │ ├── fuzzy_stack.hpp │ └── fuzzy_packet.hpp ├── test ├── unit │ ├── stl │ │ └── .keep │ ├── performance │ │ └── .keep │ ├── fs │ │ ├── memdisk.fat │ │ └── unit_fs.cpp │ ├── kernel │ │ ├── cpuid.cpp │ │ ├── arch.cpp │ │ └── blocking.cpp │ └── util │ │ ├── corrupt-tar-gz.sh │ │ └── config.cpp ├── integration │ ├── hw │ │ ├── serial │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── run.sh │ │ │ ├── Makefile │ │ │ └── test.py │ │ ├── vga │ │ │ ├── debug.sh │ │ │ ├── vbox.sh │ │ │ ├── service.gdb │ │ │ ├── run.sh │ │ │ ├── test.sh │ │ │ └── Makefile │ │ └── virtio_queue │ │ │ ├── run.sh │ │ │ ├── test.sh │ │ │ └── README.md │ ├── performance │ │ └── .keep │ ├── fs │ │ ├── memdisk │ │ │ ├── sector0.disk │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ ├── bigdisk.sh │ │ │ ├── CMakeLists.txt │ │ │ └── README.md │ │ ├── fat16 │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── disk │ │ │ │ └── banana.txt │ │ │ └── banana.ascii │ │ ├── virtio_block │ │ │ ├── README.md │ │ │ ├── cleanup.sh │ │ │ ├── vm.json │ │ │ ├── image.sh │ │ │ └── test.py │ │ ├── vfs │ │ │ ├── README.md │ │ │ ├── memdisk │ │ │ │ ├── users │ │ │ │ │ ├── alfred │ │ │ │ │ │ ├── etc │ │ │ │ │ │ │ ├── ip4 │ │ │ │ │ │ │ │ └── config.txt │ │ │ │ │ │ │ └── ip6 │ │ │ │ │ │ │ │ └── config.txt │ │ │ │ │ │ └── private │ │ │ │ │ │ │ ├── secret_plan_step1.txt │ │ │ │ │ │ │ └── secret_plan_step2.txt │ │ │ │ │ └── ingve │ │ │ │ │ │ └── etc │ │ │ │ │ │ └── ip4 │ │ │ │ │ │ └── config.txt │ │ │ │ └── README.md │ │ │ ├── virtio1 │ │ │ │ └── txt │ │ │ │ │ └── quote.txt │ │ │ ├── virtio2 │ │ │ │ └── txt │ │ │ │ │ └── quote.txt │ │ │ ├── vm.json │ │ │ ├── create_disk.sh │ │ │ └── CMakeLists.txt │ │ ├── ide │ │ │ ├── vm.json │ │ │ ├── CMakeLists.txt │ │ │ ├── banana.txt │ │ │ ├── README.md │ │ │ └── banana.ascii │ │ ├── fat32 │ │ │ ├── vm.json │ │ │ ├── banana.txt │ │ │ ├── README.md │ │ │ ├── CMakeLists.txt │ │ │ └── banana.ascii │ │ └── ide_write │ │ │ ├── vm.json │ │ │ ├── CMakeLists.txt │ │ │ ├── fat32_disk.sh │ │ │ ├── banana.txt │ │ │ ├── README.md │ │ │ └── banana.ascii │ ├── net │ │ ├── tcp │ │ │ ├── .gitignore │ │ │ ├── vm.json │ │ │ ├── CMakeLists.txt │ │ │ └── linux │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── run.sh │ │ ├── dns │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── nat │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── vlan │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── icmp │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── slaac │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── websocket │ │ │ ├── setup.sh │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── icmp6 │ │ │ ├── setup.sh │ │ │ ├── vm.json │ │ │ ├── linux │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── run.sh │ │ │ └── CMakeLists.txt │ │ ├── router6 │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── http │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── run.sh │ │ │ └── CMakeLists.txt │ │ ├── microLB │ │ │ ├── setup.sh │ │ │ └── vm.json │ │ ├── dhclient │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── configure │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── udp │ │ │ ├── vm.json │ │ │ ├── CMakeLists.txt │ │ │ └── README.md │ │ ├── dhcpd │ │ │ ├── setup.sh │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── router │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── dhcpd_dhclient_linux │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ └── CMakeLists.txt │ │ ├── bufstore │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ └── gateway │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ ├── posix │ │ ├── file_fd │ │ │ ├── disk │ │ │ │ ├── file1 │ │ │ │ ├── file2 │ │ │ │ ├── file3 │ │ │ │ ├── folder1 │ │ │ │ │ ├── file1 │ │ │ │ │ ├── file2 │ │ │ │ │ ├── foldera │ │ │ │ │ │ └── file1 │ │ │ │ │ ├── folderb │ │ │ │ │ │ └── file1 │ │ │ │ │ └── folderc │ │ │ │ │ │ └── file1 │ │ │ │ ├── folder2 │ │ │ │ │ └── file1 │ │ │ │ └── folder3 │ │ │ │ │ ├── file1 │ │ │ │ │ └── file2 │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── run.sh │ │ │ ├── vm.json │ │ │ ├── config.json │ │ │ └── CMakeLists.txt │ │ ├── stat │ │ │ ├── disk │ │ │ │ ├── file1 │ │ │ │ ├── file2 │ │ │ │ ├── folder1 │ │ │ │ │ ├── file1 │ │ │ │ │ ├── file2 │ │ │ │ │ ├── foldera │ │ │ │ │ │ └── file1 │ │ │ │ │ ├── folderb │ │ │ │ │ │ └── file1 │ │ │ │ │ └── folderc │ │ │ │ │ │ └── file1 │ │ │ │ ├── folder2 │ │ │ │ │ └── file1 │ │ │ │ ├── folder3 │ │ │ │ │ ├── file1 │ │ │ │ │ └── file2 │ │ │ │ └── file3 │ │ │ ├── vm.json │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── run.sh │ │ │ ├── config.json │ │ │ └── CMakeLists.txt │ │ ├── conf │ │ │ ├── vm.json │ │ │ ├── config.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── syslog_default │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── udp │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── utsname │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── tcp │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ │ ├── pthread │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── syslog_plugin │ │ │ ├── vm.json │ │ │ ├── config.json │ │ │ ├── CMakeLists.txt │ │ │ └── README.md │ │ └── main │ │ │ ├── README.md │ │ │ ├── main_no_params.cpp │ │ │ └── CMakeLists.txt │ ├── kernel │ │ ├── grub │ │ │ ├── .gitignore │ │ │ ├── vm.json │ │ │ ├── setup.sh │ │ │ ├── grub.cfg │ │ │ ├── test.py │ │ │ ├── README.md │ │ │ └── grubiso.sh │ │ ├── block │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── context │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── rng │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── tls │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── memmap │ │ │ ├── vm1.json │ │ │ ├── README.md │ │ │ ├── vm2.json │ │ │ ├── CMakeLists.txt │ │ │ └── test.py │ │ ├── modules │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── plugin_init │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── plugin2.cpp │ │ │ ├── test.py │ │ │ ├── CMakeLists.txt │ │ │ ├── plugin3.cpp │ │ │ └── plugin1.cpp │ │ ├── timers │ │ │ ├── README.md │ │ │ ├── vm.json │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── fiber │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── smp │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── CMakeLists.txt │ │ │ └── test.py │ │ ├── stacktrace │ │ │ ├── vm.json │ │ │ ├── service.cpp │ │ │ ├── CMakeLists.txt │ │ │ └── test.py │ │ ├── kprint │ │ │ ├── README.md │ │ │ └── CMakeLists.txt │ │ ├── exception │ │ │ ├── vm.json │ │ │ ├── CMakeLists.txt │ │ │ └── test.py │ │ ├── LiveUpdate │ │ │ ├── manual.sh │ │ │ ├── vm.json │ │ │ └── test.py │ │ ├── osinit │ │ │ ├── service.cpp │ │ │ ├── CMakeLists.txt │ │ │ └── test.py │ │ ├── term │ │ │ ├── vm.json │ │ │ ├── CMakeLists.txt │ │ │ └── test.py │ │ └── spinlocks │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ ├── README.md │ ├── stl │ │ ├── exceptions │ │ │ ├── .gitignore │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ └── CMakeLists.txt │ │ ├── coroutines │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ ├── crt │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ │ └── stl │ │ │ ├── test.py │ │ │ ├── CMakeLists.txt │ │ │ └── README.md │ ├── util │ │ ├── tar │ │ │ ├── README.md │ │ │ ├── tar_example │ │ │ │ ├── first_file.txt │ │ │ │ ├── second_file.md │ │ │ │ └── l1_f1 │ │ │ │ │ └── l2 │ │ │ │ │ └── README.md │ │ │ └── vm.json │ │ └── tar_gz │ │ │ ├── README.md │ │ │ ├── tar_example │ │ │ ├── first_file.txt │ │ │ ├── second_file.md │ │ │ └── l1_f1 │ │ │ │ └── l2 │ │ │ │ └── README.md │ │ │ └── vm.json │ ├── memory │ │ └── paging │ │ │ ├── vm.json │ │ │ └── CMakeLists.txt │ ├── plugin │ │ └── unik │ │ │ ├── vm.json │ │ │ ├── README.md │ │ │ ├── test.py │ │ │ └── CMakeLists.txt │ └── mod │ │ └── gsl │ │ ├── test.py │ │ ├── CMakeLists.txt │ │ └── README.md ├── .gitignore ├── userspace │ ├── fuzz │ │ ├── .gitignore │ │ ├── test.sh │ │ ├── apply_payloads.sh │ │ ├── continous_fuzz.sh │ │ ├── macfuzzy.hpp │ │ └── CMakeLists.txt │ ├── s2n │ │ ├── .gitignore │ │ ├── memdisk.fat │ │ ├── test.sh │ │ ├── serial.hpp │ │ └── CMakeLists.txt │ ├── tcp │ │ ├── .gitignore │ │ ├── pgo.sh │ │ ├── test.sh │ │ └── CMakeLists.txt │ ├── liveupdate │ │ ├── .gitignore │ │ ├── test.sh │ │ └── CMakeLists.txt │ ├── websockets │ │ ├── .gitignore │ │ ├── memdisk.fat │ │ └── CMakeLists.txt │ ├── microlb │ │ ├── memdisk.fat │ │ ├── run_test.sh │ │ ├── README.md │ │ ├── run_cgroup.sh │ │ ├── CMakeLists.txt │ │ └── client.py │ └── router │ │ └── CMakeLists.txt ├── misc │ ├── lest_util │ │ ├── posix_strace.hpp │ │ ├── malloc.h │ │ ├── stdlib.h │ │ ├── random.cpp │ │ └── lestmain.cxx │ ├── solo5-hvt │ │ ├── manual.sh │ │ └── build.sh │ ├── run_unit_tests │ │ └── test.sh │ ├── test_solo5_spt.sh │ └── test_solo5_hvt.sh └── stress │ └── net │ ├── vm.json │ ├── README.md │ └── CMakeLists.txt ├── src ├── plugins │ └── system_log.cpp ├── arch │ ├── CMakeLists.txt │ ├── aarch64 │ │ ├── macros.h │ │ └── arch_musl.cpp │ ├── i686 │ │ ├── arch_musl.cpp │ │ └── CMakeLists.txt │ └── x86_64 │ │ └── CMakeLists.txt ├── memdisk │ ├── empty.asm │ └── memdisk.asm ├── drivers │ └── ip4_reassembly.cpp ├── chainload │ ├── layout.txt │ └── CMakeLists.txt ├── hal │ └── CMakeLists.txt ├── crt │ ├── crtn.asm │ ├── crti.asm │ └── CMakeLists.txt ├── posix │ ├── secure_getenv.cpp │ └── CMakeLists.txt ├── kernel │ └── rtc.cpp ├── platform │ ├── aarch64_vm │ │ ├── platform.hpp │ │ ├── exception_handling.hpp │ │ ├── init_libc.hpp │ │ └── stop.asm │ ├── kvm │ │ └── kvmclock.hpp │ ├── x86_pc │ │ ├── init_libc.hpp │ │ └── boot │ │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ ├── x86_nano │ │ └── CMakeLists.txt │ └── x86_solo5 │ │ └── serial1.cpp ├── musl │ ├── getpid.cpp │ ├── getuid.cpp │ ├── _lseek.cpp │ ├── syscall_n.cpp │ ├── sched_yield.cpp │ ├── getgid.cpp │ ├── fsync.cpp │ ├── setsid.cpp │ ├── fchdir.cpp │ ├── geteuid.cpp │ ├── setgid.cpp │ ├── setuid.cpp │ ├── sysinfo.cpp │ ├── msync.cpp │ ├── setpgid.cpp │ ├── fchown.cpp │ ├── getrlimit.cpp │ ├── ftruncate.cpp │ ├── getrusage.cpp │ ├── rmdir.cpp │ ├── setrlimit.cpp │ ├── chown.cpp │ ├── mprotect.cpp │ ├── unlink.cpp │ ├── set_robust_list.cpp │ ├── sync.cpp │ ├── fchmod.cpp │ ├── chmod.cpp │ ├── mkdir.cpp │ ├── creat.cpp │ ├── gettid.cpp │ ├── readlink.cpp │ ├── umask.cpp │ ├── openat.cpp │ ├── close.cpp │ ├── sigaltstack.cpp │ ├── execve.cpp │ ├── getrandom.cpp │ ├── rename.cpp │ ├── mknod.cpp │ ├── munmap.cpp │ ├── mkdirat.cpp │ ├── mincore.cpp │ ├── mknodat.cpp │ ├── faccessat.cpp │ ├── fchmodat.cpp │ ├── readv.cpp │ ├── faccessat2.cpp │ ├── fchmodat2.cpp │ ├── read.cpp │ ├── wait4.cpp │ ├── sched_setscheduler.cpp │ ├── statx.cpp │ ├── exit.cpp │ ├── set_tid_address.cpp │ ├── fcntl.cpp │ ├── sched_getaffinity.cpp │ ├── sched_setaffinity.cpp │ ├── mremap.cpp │ ├── getdents.cpp │ ├── fstat.cpp │ ├── pipe.cpp │ ├── gettimeofday.cpp │ ├── mlock.cpp │ ├── rt_sigaction.cpp │ ├── prlimit64.cpp │ ├── uname.cpp │ ├── select.cpp │ ├── write.cpp │ ├── writev.cpp │ ├── dup3.cpp │ ├── kill.cpp │ └── ioctl.cpp ├── virtio │ └── CMakeLists.txt ├── fs │ └── CMakeLists.txt ├── hw │ └── CMakeLists.txt ├── util │ ├── pmr_default.cpp │ └── CMakeLists.txt └── net │ ├── tcp │ └── stream.cpp │ └── ip6 │ └── packet_mld.cpp ├── vmbuild └── .gitignore ├── misc ├── logo.png ├── linux │ ├── lxp-gprof │ ├── lxp-debug │ ├── lxp-pgo │ └── lxp-callgraph └── debug │ └── service.gdb ├── lib └── LiveUpdate │ ├── layout.txt │ └── README.md ├── cmake ├── cpu_feat.cmake ├── vanilla.cmake └── includeos-config.cmake.in ├── deps ├── musl │ └── patches │ │ ├── __set_thread_area.c │ │ └── endian.patch ├── botan │ ├── WIP.md │ └── default.nix ├── libfdt │ └── CMakeLists.txt └── lest │ └── default.nix ├── pinned.nix ├── userspace ├── src │ ├── epoll_evloop.hpp │ ├── profile.cpp │ └── CMakeLists.txt └── CMakeLists.txt ├── NOTICE ├── example └── src │ └── main.cpp ├── CONTRIBUTE.md ├── vmbuild.nix ├── .editorconfig └── default.nix /api/net/http/parse.hpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/stl/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/plugins/system_log.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/performance/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/hw/serial/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/performance/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/fs/memdisk/sector0.disk: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vmbuild/.gitignore: -------------------------------------------------------------------------------- 1 | elf_syms 2 | vmbuild 3 | -------------------------------------------------------------------------------- /test/integration/net/tcp/.gitignore: -------------------------------------------------------------------------------- 1 | test_tcp 2 | -------------------------------------------------------------------------------- /src/arch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(${ARCH}) 2 | -------------------------------------------------------------------------------- /test/integration/net/dns/README.md: -------------------------------------------------------------------------------- 1 | # DNS Test 2 | -------------------------------------------------------------------------------- /test/integration/net/nat/README.md: -------------------------------------------------------------------------------- 1 | # Test NAT 2 | -------------------------------------------------------------------------------- /test/integration/net/vlan/README.md: -------------------------------------------------------------------------------- 1 | # Test VLAN 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/.gitignore: -------------------------------------------------------------------------------- 1 | temp_disk/ 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/file2: -------------------------------------------------------------------------------- 1 | more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/file2: -------------------------------------------------------------------------------- 1 | more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder1/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder2/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder3/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /src/memdisk/empty.asm: -------------------------------------------------------------------------------- 1 | USE32 2 | section .diskdata 3 | 4 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | *.gcov 2 | *.gcda 3 | *.gcno 4 | unittests 5 | -------------------------------------------------------------------------------- /test/integration/README.md: -------------------------------------------------------------------------------- 1 | # IncludeOS integration test 2 | -------------------------------------------------------------------------------- /test/integration/net/icmp/README.md: -------------------------------------------------------------------------------- 1 | # ICMP integration test 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/file3: -------------------------------------------------------------------------------- 1 | even more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder1/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder2/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder3/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/file3: -------------------------------------------------------------------------------- 1 | even more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder1/file2: -------------------------------------------------------------------------------- 1 | more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder3/file2: -------------------------------------------------------------------------------- 1 | more content 2 | -------------------------------------------------------------------------------- /test/integration/stl/exceptions/.gitignore: -------------------------------------------------------------------------------- 1 | /test_exceptions 2 | -------------------------------------------------------------------------------- /test/integration/util/tar/README.md: -------------------------------------------------------------------------------- 1 | # Tar Test Service 2 | 3 | -------------------------------------------------------------------------------- /src/drivers/ip4_reassembly.cpp: -------------------------------------------------------------------------------- 1 | /* to be removed eventually */ 2 | -------------------------------------------------------------------------------- /test/integration/fs/fat16/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "service.img" } 2 | -------------------------------------------------------------------------------- /test/integration/kernel/block/README.md: -------------------------------------------------------------------------------- 1 | # Test blocking calls 2 | -------------------------------------------------------------------------------- /test/integration/kernel/context/README.md: -------------------------------------------------------------------------------- 1 | # Test stack switching 2 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "grub.iso" } 2 | -------------------------------------------------------------------------------- /test/integration/kernel/rng/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "service.img" } 2 | -------------------------------------------------------------------------------- /test/integration/kernel/tls/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 32 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/posix/conf/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 128 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder1/file2: -------------------------------------------------------------------------------- 1 | more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder3/file2: -------------------------------------------------------------------------------- 1 | more content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder1/foldera/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder1/folderb/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/disk/folder1/folderc/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/stat/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 128 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/stl/coroutines/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "smp" : 5 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/stl/exceptions/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "smp" : 16 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/fs/virtio_block/README.md: -------------------------------------------------------------------------------- 1 | # Test Virtio block. WIP 2 | -------------------------------------------------------------------------------- /test/integration/hw/vga/debug.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gdb -x service.gdb 3 | -------------------------------------------------------------------------------- /test/integration/kernel/context/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "service.img" } 2 | -------------------------------------------------------------------------------- /test/integration/kernel/memmap/vm1.json: -------------------------------------------------------------------------------- 1 | {"image" : "service.img" } 2 | -------------------------------------------------------------------------------- /test/integration/kernel/modules/README.md: -------------------------------------------------------------------------------- 1 | # Test multiboot modules 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder1/foldera/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder1/folderb/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/disk/folder1/folderc/file1: -------------------------------------------------------------------------------- 1 | content 2 | -------------------------------------------------------------------------------- /test/integration/util/tar_gz/README.md: -------------------------------------------------------------------------------- 1 | # Tar.gz Test Service 2 | 3 | -------------------------------------------------------------------------------- /test/userspace/fuzz/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | gmon.out 3 | tcp_callgraph.png 4 | -------------------------------------------------------------------------------- /test/userspace/s2n/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | gmon.out 3 | tcp_callgraph.png 4 | -------------------------------------------------------------------------------- /test/userspace/tcp/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | gmon.out 3 | tcp_callgraph.png 4 | -------------------------------------------------------------------------------- /api/ide: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "fs/disk.hpp" 3 | #include "hw/ide.hpp" 4 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/README.md: -------------------------------------------------------------------------------- 1 | # Test IncludeOS Virtual File System 2 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/memdisk/users/alfred/etc/ip4/config.txt: -------------------------------------------------------------------------------- 1 | 10.0.0.42 2 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/memdisk/users/ingve/etc/ip4/config.txt: -------------------------------------------------------------------------------- 1 | 10.0.0.43 2 | -------------------------------------------------------------------------------- /test/integration/kernel/memmap/README.md: -------------------------------------------------------------------------------- 1 | # Test of different timers 2 | 3 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "service.img" } 2 | -------------------------------------------------------------------------------- /test/integration/kernel/timers/README.md: -------------------------------------------------------------------------------- 1 | # Test of different timers 2 | 3 | -------------------------------------------------------------------------------- /test/integration/posix/syslog_default/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 128 3 | } 4 | -------------------------------------------------------------------------------- /test/userspace/liveupdate/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | gmon.out 3 | tcp_callgraph.png 4 | -------------------------------------------------------------------------------- /test/userspace/websockets/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | gmon.out 3 | tcp_callgraph.png 4 | -------------------------------------------------------------------------------- /misc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/IncludeOS/HEAD/misc/logo.png -------------------------------------------------------------------------------- /test/integration/hw/serial/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_serial.img" 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/hw/vga/vbox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ../../etc/vboxrun.sh Test.img 3 | -------------------------------------------------------------------------------- /lib/LiveUpdate/layout.txt: -------------------------------------------------------------------------------- 1 | [includedirs] 2 | include 3 | 4 | [libdirs] 5 | build/lib 6 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/memdisk/README.md: -------------------------------------------------------------------------------- 1 | #Test content for virtual file system test 2 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/memdisk/users/alfred/private/secret_plan_step1.txt: -------------------------------------------------------------------------------- 1 | Manhattan 2 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/memdisk/users/alfred/private/secret_plan_step2.txt: -------------------------------------------------------------------------------- 1 | Berlin 2 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/virtio1/txt/quote.txt: -------------------------------------------------------------------------------- 1 | I see through the lies of the Jedi. 2 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/virtio2/txt/quote.txt: -------------------------------------------------------------------------------- 1 | Always pass on what you have learned. 2 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.img 4 | _elf_symbols.bin 5 | -------------------------------------------------------------------------------- /test/integration/posix/stat/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.img 4 | _elf_symbols.bin 5 | -------------------------------------------------------------------------------- /test/integration/posix/udp/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.img 4 | _elf_symbols.bin 5 | -------------------------------------------------------------------------------- /test/integration/fs/memdisk/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem": 256, 3 | "intrusive" : "True" 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/memdisk/users/alfred/etc/ip6/config.txt: -------------------------------------------------------------------------------- 1 | fe80::8b3:f8c7:b2ab:4934 2 | -------------------------------------------------------------------------------- /src/memdisk/memdisk.asm: -------------------------------------------------------------------------------- 1 | USE32 2 | ALIGN 4096 3 | section .diskdata 4 | incbin "testdisk" 5 | -------------------------------------------------------------------------------- /test/integration/kernel/fiber/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "service.img", 3 | "smp" : 16 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/kernel/smp/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "service.img", 3 | "smp" : 16 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/net/slaac/README.md: -------------------------------------------------------------------------------- 1 | # Test SLAAC or Auto-configuration of Slaac functionality 2 | -------------------------------------------------------------------------------- /test/misc/lest_util/posix_strace.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PRINT(x, ...) /** x **/ 4 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get -q install -qy grub-pc xorriso 3 | -------------------------------------------------------------------------------- /test/integration/kernel/memmap/vm2.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "service.img", 3 | "mem" : 2000 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/README.md: -------------------------------------------------------------------------------- 1 | # Test pre-service plugin initialization routines 2 | -------------------------------------------------------------------------------- /test/integration/kernel/stacktrace/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "service.img", 3 | "smp" : 16 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/posix/stat/README.md: -------------------------------------------------------------------------------- 1 | # POSIX stat Test 2 | 3 | Testing POSIX stat implementation. 4 | -------------------------------------------------------------------------------- /test/integration/posix/udp/README.md: -------------------------------------------------------------------------------- 1 | # POSIX UDP Test 2 | 3 | Testing POSIX UDP implementation. 4 | -------------------------------------------------------------------------------- /test/unit/fs/memdisk.fat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/IncludeOS/HEAD/test/unit/fs/memdisk.fat -------------------------------------------------------------------------------- /api/posix/stddef.h: -------------------------------------------------------------------------------- 1 | #define _DYNAMIC 2 | 3 | 4 | #define _GCC_MAX_ALIGN_T 5 | #include_next 6 | -------------------------------------------------------------------------------- /test/integration/hw/vga/service.gdb: -------------------------------------------------------------------------------- 1 | file Test 2 | break Service::start 3 | target remote localhost:1234 4 | -------------------------------------------------------------------------------- /test/integration/kernel/block/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "blocking.img", 2 | "time_sensitive" : "True" 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/kernel/fiber/README.md: -------------------------------------------------------------------------------- 1 | # Test kprint - the earliest available kernel printing facility 2 | -------------------------------------------------------------------------------- /test/integration/kernel/kprint/README.md: -------------------------------------------------------------------------------- 1 | # Test kprint - the earliest available kernel printing facility 2 | -------------------------------------------------------------------------------- /test/integration/net/websocket/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | sudo -H pip -q install ws4py==0.4.2 4 | -------------------------------------------------------------------------------- /misc/linux/lxp-gprof: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | echo -e "\n>>> Running service with profiling" 3 | source lxp-run gprof 4 | -------------------------------------------------------------------------------- /src/chainload/layout.txt: -------------------------------------------------------------------------------- 1 | [includedirs] 2 | include 3 | 4 | [libdirs] 5 | build/lib 6 | [bindirs] 7 | build 8 | -------------------------------------------------------------------------------- /src/hal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCS 2 | machine.cpp 3 | ) 4 | 5 | 6 | add_library(hal OBJECT ${SRCS}) 7 | -------------------------------------------------------------------------------- /test/integration/kernel/timers/vm.json: -------------------------------------------------------------------------------- 1 | {"image" : "test_timers.img", 2 | "time_sensitive" : "True" 3 | } 4 | -------------------------------------------------------------------------------- /test/integration/net/websocket/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio"}], 3 | "mem" : 1024 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/README.md: -------------------------------------------------------------------------------- 1 | # POSIX file_fd Test 2 | 3 | Testing POSIX file_fd implementation. 4 | -------------------------------------------------------------------------------- /test/integration/posix/utsname/README.md: -------------------------------------------------------------------------------- 1 | # POSIX Utsname Test 2 | 3 | Testing POSIX Utsname implementation. 4 | -------------------------------------------------------------------------------- /test/integration/util/tar/tar_example/first_file.txt: -------------------------------------------------------------------------------- 1 | This is the first file's content. 2 | It is a text file. 3 | -------------------------------------------------------------------------------- /test/integration/kernel/exception/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description" : "CPU exception test", 3 | "mem" : 48 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/net/icmp6/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 &> /dev/null 3 | -------------------------------------------------------------------------------- /test/integration/posix/tcp/README.md: -------------------------------------------------------------------------------- 1 | # POSIX TCP Test 2 | 3 | Testing POSIX TCP implementation. VERY bare bones. 4 | -------------------------------------------------------------------------------- /test/integration/util/tar_gz/tar_example/first_file.txt: -------------------------------------------------------------------------------- 1 | This is the first file's content. 2 | It is a text file. 3 | -------------------------------------------------------------------------------- /test/userspace/s2n/memdisk.fat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/IncludeOS/HEAD/test/userspace/s2n/memdisk.fat -------------------------------------------------------------------------------- /misc/linux/lxp-debug: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | echo -e "\n>>> Running service with debugging" 3 | DBG="ON" 4 | source lxp-run 5 | -------------------------------------------------------------------------------- /test/integration/kernel/LiveUpdate/manual.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cat > /dev/tcp/10.0.0.59/666 < build/kernel_LiveUpdate 3 | -------------------------------------------------------------------------------- /test/userspace/microlb/memdisk.fat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/IncludeOS/HEAD/test/userspace/microlb/memdisk.fat -------------------------------------------------------------------------------- /test/integration/net/router6/README.md: -------------------------------------------------------------------------------- 1 | # IPv6 routing test 2 | 3 | Depends on iperf3. TODO: It currently seems to time out. 4 | -------------------------------------------------------------------------------- /test/userspace/s2n/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=gcc-7 4 | export CXX=g++-7 5 | $INCLUDEOS_PREFIX/bin/lxp-run 6 | -------------------------------------------------------------------------------- /cmake/cpu_feat.cmake: -------------------------------------------------------------------------------- 1 | set(CAPABS "-mavx2 -maes -mfpmath=sse") 2 | message(STATUS "Using native CPU features. CAPABS = ${CAPABS}") 3 | -------------------------------------------------------------------------------- /src/crt/crtn.asm: -------------------------------------------------------------------------------- 1 | section .init 2 | 3 | pop ebp 4 | ret 5 | 6 | section .fini 7 | 8 | pop ebp 9 | ret 10 | -------------------------------------------------------------------------------- /test/integration/fs/virtio_block/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Cleaning up after test..." 3 | rm image.img 4 | echo "Done" 5 | -------------------------------------------------------------------------------- /test/integration/hw/serial/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | source ${INCLUDEOS_HOME-$HOME/IncludeOS_install}/etc/run.sh test_serial.img 3 | -------------------------------------------------------------------------------- /test/integration/net/http/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 256 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/net/icmp6/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 128 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/net/microLB/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo apt-get -qqq install -y nodejs 3 | sudo -H pip -q install requests 4 | -------------------------------------------------------------------------------- /test/integration/net/tcp/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 256 4 | } 5 | -------------------------------------------------------------------------------- /test/userspace/websockets/memdisk.fat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/includeos/IncludeOS/HEAD/test/userspace/websockets/memdisk.fat -------------------------------------------------------------------------------- /test/integration/posix/file_fd/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | source ${INCLUDEOS_HOME-$HOME/IncludeOS_install}/etc/run.sh `make servicefile` 3 | -------------------------------------------------------------------------------- /test/integration/posix/pthread/README.md: -------------------------------------------------------------------------------- 1 | # POSIX threads test (Very WIP) 2 | 3 | Proof-of-concept test of pthreads on top of Fibers 4 | -------------------------------------------------------------------------------- /test/integration/posix/stat/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | source ${INCLUDEOS_HOME-$HOME/IncludeOS_install}/etc/run.sh `make servicefile` 3 | -------------------------------------------------------------------------------- /test/integration/posix/utsname/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 128 4 | } 5 | -------------------------------------------------------------------------------- /test/integration/stl/coroutines/README.md: -------------------------------------------------------------------------------- 1 | # Test Coroutines 2 | 3 | Test the C++ Couroutines compatibility with IncludeOS and SMP 4 | -------------------------------------------------------------------------------- /test/integration/util/tar/tar_example/second_file.md: -------------------------------------------------------------------------------- 1 | ## Second file 2 | 3 | This is the second file's content. 4 | 5 | The format is md. -------------------------------------------------------------------------------- /test/misc/solo5-hvt/manual.sh: -------------------------------------------------------------------------------- 1 | solo5-hvt --disk=dummy.disk --net=tap100 -- $INCLUDEOS_SRC/examples/demo_service/build_solo5-hvt/demo 2 | -------------------------------------------------------------------------------- /test/integration/hw/virtio_queue/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | source ${INCLUDEOS_HOME-$HOME/IncludeOS_install}/etc/run.sh test_virtio_queue.img 3 | -------------------------------------------------------------------------------- /test/integration/util/tar_gz/tar_example/second_file.md: -------------------------------------------------------------------------------- 1 | ## Second file 2 | 3 | This is the second file's content. 4 | 5 | The format is md. -------------------------------------------------------------------------------- /test/misc/solo5-hvt/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | pushd $INCLUDEOS_SRC/examples/demo_service/build_solo5-hvt 5 | make 6 | popd 7 | -------------------------------------------------------------------------------- /src/posix/secure_getenv.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" 4 | char* secure_getenv(const char* name) 5 | { 6 | return getenv(name); 7 | } -------------------------------------------------------------------------------- /test/integration/net/dhclient/README.md: -------------------------------------------------------------------------------- 1 | # Test DHCP functionality 2 | 3 | Note: requires a DHCP server to be present on the include0 bridge 4 | -------------------------------------------------------------------------------- /test/integration/posix/syslog_plugin/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 128 4 | } 5 | -------------------------------------------------------------------------------- /test/userspace/microlb/run_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=gcc-7 4 | export CXX=g++-7 5 | AS_ROOT=ON $INCLUDEOS_PREFIX/bin/lxp-run 6 | -------------------------------------------------------------------------------- /api/async: -------------------------------------------------------------------------------- 1 | // -*-C++-*- 2 | #pragma once 3 | #ifndef API_ASYNC_HEADER 4 | #define API_ASYNC_HEADER 5 | 6 | #include "util/async.hpp" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /api/net/inet4: -------------------------------------------------------------------------------- 1 | //-*- C++ -*- 2 | #pragma once 3 | #warning net/inet4 has changed to net/inet, please #include that instead! 4 | #include "inet.hpp" 5 | -------------------------------------------------------------------------------- /test/integration/kernel/rng/README.md: -------------------------------------------------------------------------------- 1 | # RNG Test 2 | 3 | Tests POSIX random (`open`, `read` etc on `"/dev/urandom"`) and `std::random_device`. 4 | 5 | -------------------------------------------------------------------------------- /test/integration/net/configure/README.md: -------------------------------------------------------------------------------- 1 | # Configure Test 2 | 3 | Verifies that the network config in `config.json` is getting correctly parsed. 4 | -------------------------------------------------------------------------------- /api/config: -------------------------------------------------------------------------------- 1 | // -*-C++-*- 2 | #pragma once 3 | #ifndef API_CONFIG_HEADER 4 | #define API_CONFIG_HEADER 5 | 6 | #include "util/config.hpp" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/integration/kernel/smp/README.md: -------------------------------------------------------------------------------- 1 | ### SMP 2 | 3 | ``` 4 | mkdir build 5 | cd build 6 | cmake .. 7 | make 8 | ../run.sh smp_example 9 | ``` 10 | -------------------------------------------------------------------------------- /test/integration/kernel/tls/README.md: -------------------------------------------------------------------------------- 1 | ### SMP 2 | 3 | ``` 4 | mkdir build 5 | cd build 6 | cmake .. 7 | make 8 | ../run.sh smp_example 9 | ``` 10 | -------------------------------------------------------------------------------- /test/stress/net/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "stress.elf.bin", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 4 | "mem" : 300 5 | } 6 | -------------------------------------------------------------------------------- /api/net/inet: -------------------------------------------------------------------------------- 1 | //-*- C++ -*- 2 | #pragma once 3 | #ifndef NET_INET_HEADER 4 | #define NET_INET_HEADER 5 | 6 | #include "inet.hpp" 7 | 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /test/integration/hw/vga/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | export DEV_GRAPHICS="-vga std" 3 | source ${INCLUDEOS_HOME-$HOME/IncludeOS_install}/etc/run.sh test_vga.img 4 | -------------------------------------------------------------------------------- /test/integration/net/icmp/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 128, 4 | "intrusive" : "True" 5 | } 6 | -------------------------------------------------------------------------------- /api/autoconf: -------------------------------------------------------------------------------- 1 | // -*-C++-*- 2 | #pragma once 3 | #ifndef API_AUTOCONF_HEADER 4 | #define API_AUTOCONF_HEADER 5 | 6 | #include "util/autoconf.hpp" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/integration/memory/paging/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description" : "Page protection test", 3 | "mem" : 3584, 4 | "time_sensitive": "True", 5 | "smp" : 16 6 | } 7 | -------------------------------------------------------------------------------- /test/integration/posix/tcp/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:6a"}], 3 | "mem" : 128, 4 | "time_sensitive" : "True" 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/posix/udp/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 128, 4 | "time_sensitive" : "True" 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/util/tar/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_tar.img", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 4 | "mem" : 128 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/kernel/osinit/service.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void Service::start() 5 | { 6 | kprint("Service::start entered\n"); 7 | } 8 | -------------------------------------------------------------------------------- /test/integration/util/tar_gz/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_tar_gz.img", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 4 | "mem" : 128 5 | } 6 | -------------------------------------------------------------------------------- /test/misc/lest_util/malloc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __MACH__ 3 | extern void* memalign(size_t alignment, size_t size); 4 | #else 5 | #include_next 6 | #endif 7 | -------------------------------------------------------------------------------- /test/integration/net/http/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Test 2 | 3 | ## Client 4 | Test the HTTP Client on local server. 5 | 6 | Outgoing test requires correct network configuration. 7 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_file_fd.img", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 4 | "mem" : 128 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/net/dhclient/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_dhcp.img", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 4 | "time_sensitive" : "True" 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/net/slaac/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_slaac.img", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 4 | "time_sensitive" : "True" 5 | } 6 | -------------------------------------------------------------------------------- /test/integration/net/udp/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}], 3 | "mem" : 400, 4 | "time_sensitive": "True", 5 | "smp" : 16 6 | } 7 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/grub.cfg: -------------------------------------------------------------------------------- 1 | set timeout=0 2 | set default=0 # Set the default menu entry 3 | 4 | menuentry "IncludeOS" { 5 | multiboot /boot/service 6 | boot 7 | } 8 | -------------------------------------------------------------------------------- /test/integration/kernel/term/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description" : "VM with interface for testing LiveUpdate", 3 | "net" : [ 4 | {"device" : "virtio"} 5 | ], 6 | "mem" : 128 7 | } 8 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo arp -d 10.0.0.10 2>&1 > /dev/null 4 | sudo arp -d 10.0.0.11 2>&1 > /dev/null 5 | sudo arp -d 10.0.0.12 2>&1 > /dev/null 6 | -------------------------------------------------------------------------------- /src/kernel/rtc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | RTC::timestamp_t RTC::booted_at; 4 | 5 | void RTC::init() 6 | { 7 | // set boot timestamp 8 | booted_at = now(); 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/plugin/unik/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2b"} 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /test/misc/lest_util/stdlib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #ifdef __MACH__ 4 | void* aligned_alloc(size_t alignment, size_t size); 5 | #endif 6 | 7 | #include_next 8 | -------------------------------------------------------------------------------- /src/platform/aarch64_vm/platform.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLATFORM_H 2 | #define PLATFORM_H 3 | 4 | void __platform_init(uint64_t addr); 5 | 6 | 7 | 8 | #endif /* end of include guard: 9 | */ 10 | -------------------------------------------------------------------------------- /test/integration/kernel/LiveUpdate/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description" : "VM with interface for testing LiveUpdate", 3 | "net" : [ 4 | {"device" : "virtio"} 5 | ], 6 | "mem" : 1024 7 | } 8 | -------------------------------------------------------------------------------- /test/integration/hw/virtio_queue/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source ../test_base 3 | 4 | make 5 | start test_virtio_queue.img 6 | 7 | cd ../tcp 8 | make clean && make 9 | start test_tcp.img 10 | -------------------------------------------------------------------------------- /test/integration/net/router/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "mem" : 320, 3 | "net" : [{"device" : "virtio"}, 4 | {"device" : "virtio"}], 5 | "intrusive": "True", 6 | "time_sensitive" : "True" 7 | } 8 | -------------------------------------------------------------------------------- /test/unit/kernel/cpuid.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | CASE("CPUID test") 6 | { 7 | EXPECT(!CPUID::detect_features_str().empty()); 8 | } 9 | -------------------------------------------------------------------------------- /deps/musl/patches/__set_thread_area.c: -------------------------------------------------------------------------------- 1 | #include "syscall.h" 2 | 3 | #define ARCH_SET_FS 0x1002 4 | 5 | int __set_thread_area(void *p) 6 | { 7 | return __syscall(SYS_arch_prctl, ARCH_SET_FS, p); 8 | } 9 | -------------------------------------------------------------------------------- /src/musl/getpid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | int sys_getpid() { 4 | return 1; 5 | } 6 | 7 | extern "C" 8 | long syscall_SYS_getpid() { 9 | return strace(sys_getpid, "getpid"); 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/net/vlan/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2f"} 5 | ], 6 | "mem" : 128 7 | } 8 | -------------------------------------------------------------------------------- /cmake/vanilla.cmake: -------------------------------------------------------------------------------- 1 | IF(${ARCH} STREQUAL "x86_64" OR ${ARCH} STREQUAL "i686") 2 | set(CAPABS "-msse3 -mfpmath=sse") 3 | message(STATUS "Using vanilla CPU features: SSE3. CAPABS = ${CAPABS}") 4 | ENDIF() 5 | -------------------------------------------------------------------------------- /src/virtio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCS 2 | virtio_queue.cpp 3 | ) 4 | if (NOT CMAKE_TESTING_ENABLED) 5 | list(APPEND SRCS 6 | virtio.cpp 7 | ) 8 | endif() 9 | add_library(virtio OBJECT ${SRCS}) 10 | -------------------------------------------------------------------------------- /test/misc/run_unit_tests/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INCLUDEOS_SRC=${INCLUDEOS_SRC-$HOME/IncludeOS} 4 | ARCH=${ARCH:-x86_64} 5 | 6 | pushd $INCLUDEOS_SRC/build_$ARCH/unittests 7 | ./unittests --pass 8 | popd 9 | -------------------------------------------------------------------------------- /src/musl/getuid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static long sys_getuid() { 4 | return 0; 5 | } 6 | 7 | extern "C" 8 | long syscall_SYS_getuid() { 9 | return strace(sys_getuid, "getuid"); 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/fs/ide/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "drives" : [{ 3 | "file" : "../my.disk", 4 | "type" : "ide", 5 | "format" : "raw", 6 | "media" : "disk" 7 | }], 8 | "intrusive" : "True" 9 | } 10 | -------------------------------------------------------------------------------- /test/unit/util/corrupt-tar-gz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INFILE="$1" 3 | OUTFILE="$2" 4 | 5 | printf '\x0a\x0f\x0a\x0f\x0a\x0f\x0a\x0f' | dd conv=notrunc bs=1 of=$OUTFILE seek=$((`ls -nl $INFILE | awk '{print $5}'` - 8)) 6 | -------------------------------------------------------------------------------- /pinned.nix: -------------------------------------------------------------------------------- 1 | import ( 2 | builtins.fetchTarball { 3 | url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/25.05.tar.gz"; 4 | sha256 = "1915r28xc4znrh2vf4rrjnxldw2imysz819gzhk9qlrkqanmfsxd"; 5 | } 6 | ) 7 | -------------------------------------------------------------------------------- /test/integration/fs/fat32/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "drives" : [{ 3 | "file" : "my.disk", 4 | "type" : "virtio", 5 | "format" : "raw", 6 | "media" : "disk" 7 | }], 8 | "intrusive" : "True" 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/fs/ide_write/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "drives" : [{ 3 | "file" : "../my.disk", 4 | "type" : "ide", 5 | "format" : "raw", 6 | "media" : "disk" 7 | }], 8 | "intrusive" : "True" 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/posix/syslog_plugin/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "syslog": { 3 | "type": "udp", 4 | "path": "/dev/log", 5 | "iface": 0, 6 | "address": "10.0.0.2", 7 | "port": 6514 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/crt/crti.asm: -------------------------------------------------------------------------------- 1 | global _init 2 | global _fini 3 | 4 | section .init 5 | _init: 6 | push ebp 7 | mov DWORD ebp, esp 8 | 9 | 10 | section .fini 11 | _fini: 12 | push ebp 13 | mov DWORD ebp, esp 14 | -------------------------------------------------------------------------------- /src/musl/_lseek.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | 3 | static long sys__lseek() 4 | { 5 | return -ENOSYS; 6 | } 7 | 8 | extern "C" 9 | long syscall_SYS__lseek() { 10 | return stubtrace(sys__lseek, "_lseek"); 11 | } 12 | -------------------------------------------------------------------------------- /test/integration/kernel/stacktrace/service.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void Service::start() 4 | { 5 | printf("Calling os::print_backtrace()\n"); 6 | os::print_backtrace(); 7 | printf("We reached the end.\n"); 8 | } 9 | -------------------------------------------------------------------------------- /cmake/includeos-config.cmake.in: -------------------------------------------------------------------------------- 1 | # Config file to be picked up by find_package() 2 | @PACKAGE_INIT@ 3 | set(ARCH "x86_64") 4 | set(INCLUDEOS_PACKAGE @CMAKE_INSTALL_PREFIX@) 5 | set(CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/cmake) 6 | -------------------------------------------------------------------------------- /src/musl/syscall_n.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | 3 | long syscall(long /*number*/) 4 | { 5 | return -ENOSYS; 6 | } 7 | 8 | extern "C" 9 | long syscall_n(long i) { 10 | return stubtrace(syscall, "syscall", i); 11 | } 12 | -------------------------------------------------------------------------------- /test/integration/fs/virtio_block/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "drives" : [{"file" : "image.img", 3 | "type" : "virtio", 4 | "format": "raw", 5 | "media": "disk" }], 6 | "intrusive" : "True" 7 | } 8 | -------------------------------------------------------------------------------- /test/integration/posix/conf/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "vfs" : [ 3 | { 4 | "disk" : "memdisk", 5 | "root" : "/files", 6 | "mount" : "/etc", 7 | "description" : "test fs" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/posix/stat/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "vfs" : [ 3 | { 4 | "disk" : "memdisk", 5 | "root" : "/", 6 | "mount" : "/mnt/disk/", 7 | "description" : "test root" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/net/dns/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | { 4 | "device" : "vmxnet3", "mac" : "c0:01:0a:00:00:2a", 5 | "backend" : "user" 6 | } 7 | ], 8 | "mem" : 128, 9 | "intrusive" : "True" 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/net/router6/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "test_router.img", 3 | "mem" : 320, 4 | "net" : [{"device" : "virtio"}, 5 | {"device" : "virtio"}], 6 | "intrusive": "True", 7 | "time_sensitive" : "True" 8 | } 9 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "vfs" : [ 3 | { 4 | "disk" : "memdisk", 5 | "root" : "/", 6 | "mount" : "/mnt/disk", 7 | "description" : "test root" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/posix/main/README.md: -------------------------------------------------------------------------------- 1 | # Test "main" 2 | 3 | Test / show how to make a service that only has a "main" and no "Service::start" 4 | 5 | Success: Outputs SUCCESS if all tests pass 6 | Fail: Panic on any failed tests 7 | -------------------------------------------------------------------------------- /test/misc/lest_util/random.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | // Random addresses to test for each PML 3 | namespace test { 4 | uint64_t rand64(){ 5 | static std::mt19937_64 mt_rand(time(0)); 6 | return mt_rand(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/userspace/microlb/README.md: -------------------------------------------------------------------------------- 1 | ### 2 | 3 | ``` 4 | $ ./create_bridge.sh bridge44 255.255.255.0 10.0.1.1 c0:ff:0a:00:00:01 5 | $ sudo ip addr flush dev bridge43 6 | $ sudo ip addr flush dev bridge44 7 | $ nodejs server.js 8 | ``` 9 | -------------------------------------------------------------------------------- /test/integration/kernel/modules/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [{"device" : "virtio"}], 3 | "image" : "kernel_modules.img", 4 | "modules" : [ 5 | {"path" : "kernel_modules", "args" : "loaded as module"} 6 | ], 7 | "mem" : 128 8 | } 9 | -------------------------------------------------------------------------------- /userspace/src/epoll_evloop.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace linux 5 | { 6 | void epoll_add_fd(int fd, epoll_event& event); 7 | void epoll_del_fd(int fd); 8 | void epoll_wait_events(); 9 | } 10 | -------------------------------------------------------------------------------- /src/musl/sched_yield.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | 3 | static long sys_sched_yield() 4 | { 5 | return 0; 6 | } 7 | 8 | extern "C" 9 | long syscall_SYS_sched_yield() { 10 | return stubtrace(sys_sched_yield, "sched_yield"); 11 | } 12 | -------------------------------------------------------------------------------- /test/integration/kernel/timers/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | vmrunner.vms[0].boot(60, image_name="kernel_timers.elf.bin") 10 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd_dhclient_linux/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "test_dhcp_server_dhclient.img", 3 | "net": [ 4 | { 5 | "device": "virtio", 6 | "mac": "c0:01:0a:00:00:2a" 7 | } 8 | ], 9 | "mem": 128 10 | } 11 | -------------------------------------------------------------------------------- /src/musl/getgid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_getgid() 5 | { 6 | return 0; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_getgid() 11 | { 12 | return strace(sys_getgid, "getgid"); 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/hw/vga/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source ../test_base 3 | 4 | export DEV_GRAPHICS="-vga std" 5 | make SERVICE=Test FILES=vga.cpp 6 | start Test.img "VGA: Verify that the service starts test" 7 | make SERVICE=Test FILES=vga.cpp clean 8 | -------------------------------------------------------------------------------- /test/integration/stl/coroutines/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | 6 | from vmrunner import vmrunner 7 | vm=vmrunner.vms[0] 8 | 9 | vm.boot(40,image_name='stl_coroutines.elf.bin') 10 | -------------------------------------------------------------------------------- /test/integration/kernel/modules/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import os 5 | 6 | from vmrunner import vmrunner 7 | 8 | vm = vmrunner.vms[0]; 9 | # Build, run and clean 10 | vm.boot(image_name='kernel_modules.elf.bin') 11 | -------------------------------------------------------------------------------- /test/integration/net/microLB/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "description" : "VM with 3 interfaces for load balancing", 3 | "net" : [ 4 | {"device" : "virtio"}, 5 | {"device" : "virtio"}, 6 | {"device" : "virtio"} 7 | ], 8 | "mem" : 256 9 | } 10 | -------------------------------------------------------------------------------- /test/userspace/liveupdate/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=gcc-7 4 | export CXX=g++-7 5 | $INCLUDEOS_PREFIX/bin/lxp-run 6 | 7 | if [ $? == 0 ]; then 8 | echo ">>> Linux Userspace TCP test success!" 9 | else 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /test/integration/posix/pthread/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | vm = vmrunner.vms[0] 9 | 10 | vm.boot(20,image_name='posix_pthread.elf.bin') 11 | -------------------------------------------------------------------------------- /test/userspace/fuzz/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=clang-6.0 4 | export CXX=clang++-6.0 5 | RUN=OFF $INCLUDEOS_PREFIX/bin/lxp-run 6 | 7 | if [ $? == 0 ]; then 8 | echo ">>> Building fuzzer success!" 9 | else 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /test/integration/net/http/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set - 3 | INCLUDEOS_PREFIX=${INCLUDEOS_PREFIX-/usr/local} 4 | sudo $INCLUDEOS_PREFIX/includeos/scripts/create_bridge.sh 5 | 6 | FILE=$1 7 | shift 8 | source $INCLUDEOS_PREFIX/includeos/scripts/run.sh $FILE ${*} 9 | -------------------------------------------------------------------------------- /test/integration/posix/main/main_no_params.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | printf("Hello main - %s\n", os::cmdline_args()); 6 | assert(os::cmdline_args() == std::string("test_main booted with vmrunner")); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/unit/kernel/arch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | CASE("Testing arch.hpp") 5 | { 6 | // TODO: some way to verify these? 7 | __arch_hw_barrier(); // __builtin_sync_synchronize() equivalent 8 | __sw_barrier(); 9 | } 10 | -------------------------------------------------------------------------------- /src/musl/fsync.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_fsync(int /*fd*/) 5 | { 6 | return -EROFS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_fsync(int fd) 11 | { 12 | return strace(sys_fsync, "fsync", fd); 13 | } 14 | -------------------------------------------------------------------------------- /src/musl/setsid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | long sys_setsid() 6 | { 7 | return 0; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_setsid() 12 | { 13 | return strace(sys_setsid, "setsid"); 14 | } 15 | -------------------------------------------------------------------------------- /misc/debug/service.gdb: -------------------------------------------------------------------------------- 1 | set architecture i386:x86-64 2 | 3 | break OS::start 4 | break Service::start 5 | break main 6 | 7 | set step-mode on 8 | set non-stop off 9 | target remote localhost:1234 10 | 11 | # To use the GDB_ENTRY macro, uncomment: 12 | set $eax=1 13 | -------------------------------------------------------------------------------- /src/fs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | SET(SRCS 3 | disk.cpp 4 | filesystem.cpp 5 | dirent.cpp 6 | mbr.cpp 7 | path.cpp 8 | fat.cpp 9 | fat_async.cpp 10 | fat_sync.cpp 11 | memdisk.cpp 12 | ) 13 | 14 | add_library(fs OBJECT ${SRCS}) 15 | -------------------------------------------------------------------------------- /src/hw/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCS 2 | pci_device.cpp 3 | pci_manager.cpp 4 | nic.cpp 5 | ps2.cpp 6 | serial.cpp 7 | vga_gfx.cpp 8 | msi.cpp 9 | pci_msi.cpp 10 | usernet.cpp 11 | ) 12 | 13 | 14 | add_library(hw OBJECT ${SRCS}) 15 | -------------------------------------------------------------------------------- /src/musl/fchdir.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_fchdir(int /*fd*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_fchdir(int fd) 11 | { 12 | return strace(sys_fchdir, "fchown", fd); 13 | } 14 | -------------------------------------------------------------------------------- /src/posix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(SRCS 2 | fd.cpp 3 | 4 | ) 5 | if (NOT CMAKE_TESTING_ENABLED) 6 | list(APPEND SRCS 7 | file_fd.cpp 8 | tcp_fd.cpp 9 | udp_fd.cpp 10 | unix_fd.cpp 11 | ) 12 | endif() 13 | add_library(posix OBJECT ${SRCS}) 14 | -------------------------------------------------------------------------------- /test/userspace/tcp/pgo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=gcc-7 4 | export CXX=g++-7 5 | $INCLUDEOS_PREFIX/bin/lxp-pgo | grep 'Server received' 6 | 7 | if [ $? == 0 ]; then 8 | echo ">>> Linux Userspace TCP test success!" 9 | else 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /test/userspace/tcp/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=gcc-7 4 | export CXX=g++-7 5 | $INCLUDEOS_PREFIX/bin/lxp-run | grep 'Server received' 6 | 7 | if [ $? == 0 ]; then 8 | echo ">>> Userspace TCP benchmark success!" 9 | else 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | IncludeOS - A Resource Efficient Unikernel for Cloud Services 2 | 3 | Copyright 2015 Oslo and Akershus University College of Applied Sciences 4 | and Alfred Bratterud 5 | 6 | This product includes software developed at 7 | IncludeOS (http://www.includeos.org/). 8 | 9 | -------------------------------------------------------------------------------- /src/musl/geteuid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_geteuid() 6 | { 7 | return 0; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_geteuid() 12 | { 13 | return strace(sys_geteuid, "geteuid"); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/hw/virtio_queue/README.md: -------------------------------------------------------------------------------- 1 | # Test Virtio::Queue. WIP 2 | 3 | Sucess: Outputs SUCCESS if all tests pass 4 | Fail: Panic if any test fails 5 | 6 | NOTE: This test uses the `lest` unit test framework as well for some tests. The result of those tests will also be reported. 7 | -------------------------------------------------------------------------------- /test/integration/net/bufstore/README.md: -------------------------------------------------------------------------------- 1 | # Test net::BufferStore and net::Packet chaining 2 | 3 | Internal tests that verifies that packet chaining plays well with the buffer store, i.e. that you can chain lots of packets, dechain, and they all return their buffers back to the bufstore. 4 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd/README.md: -------------------------------------------------------------------------------- 1 | # Test DHCP server 2 | 3 | Note: 4 | Requires that $INCLUDEOS_PREFIX/includeos/scripts/create_bridge.sh has been run and that a route has been added to the created bridge (bridge43): sudo route add -net 10.0.100.0 netmask 255.255.255.0 dev bridge43 5 | -------------------------------------------------------------------------------- /api/likely: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | // remove me when c++20 3 | #pragma once 4 | #ifndef INCLUDEOS_BRANCH_PRED_HEADER 5 | #define INCLUDEOS_BRANCH_PRED_HEADER 6 | 7 | #define LIKELY(x) __builtin_expect(!!(x), 1) 8 | #define UNLIKELY(x) __builtin_expect(!!(x), 0) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/platform/aarch64_vm/exception_handling.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPTION_HANDLING_H 2 | #define EXCEPTION_HANDLING_H 3 | typedef void (*irq_handler_t)(); 4 | void register_handler(uint16_t irq, irq_handler_t handler); 5 | void unregiser_handler(uint16_t irq); 6 | 7 | #endif //EXCEPTION_HANDLING_H 8 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | import subprocess 7 | 8 | from vmrunner import vmrunner 9 | 10 | vm = vmrunner.vms[0]; 11 | 12 | # Create the GRUB image 13 | vm.boot(20, multiboot = False) 14 | -------------------------------------------------------------------------------- /src/musl/setgid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | long sys_setgid(gid_t /*gid*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_setgid(gid_t gid) 12 | { 13 | return strace(sys_setgid, "setgid", gid); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/setuid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | long sys_setuid(uid_t /*uid*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_setuid(uid_t uid) 12 | { 13 | return strace(sys_setuid, "setuid", uid); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/mod/gsl/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | if len(sys.argv) > 1: 9 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 10 | else: 11 | vmrunner.vms[0].cmake().boot(60) 12 | -------------------------------------------------------------------------------- /test/integration/plugin/unik/README.md: -------------------------------------------------------------------------------- 1 | # Test the Unik plugin initialization module 2 | 3 | *Note:* The test service needs to receive an UDP heartbeat on the Unik default port, and register it's mac-address over HTTP to the sender of the heartbeat in order for the test to succeed. This is future work. 4 | -------------------------------------------------------------------------------- /test/integration/stl/crt/README.md: -------------------------------------------------------------------------------- 1 | # Test C runtime 2 | Essentially this tests global constructors, which needs crti.o, crtn.o etc. to be linked in properly to work. 3 | 4 | Internal test, self-explanatory output. 5 | 6 | Success: Outputs SUCCESS if all tests pass 7 | Fail: Panic on any failed tests 8 | -------------------------------------------------------------------------------- /test/misc/lest_util/lestmain.cxx: -------------------------------------------------------------------------------- 1 | #include "common.cxx" 2 | 3 | lest::tests& specification() 4 | { 5 | static lest::tests tests; 6 | return tests; 7 | } 8 | 9 | int main( int argc, char * argv[] ) 10 | { 11 | return lest::run( specification(), argc, argv /*, std::cout */ ); 12 | } 13 | -------------------------------------------------------------------------------- /userspace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(../api) 2 | include_directories(../mod) 3 | include_directories(../mod/GSL) 4 | include_directories(../src/include) 5 | 6 | add_subdirectory(src) 7 | if (BUILD_PLUGINS) 8 | add_subdirectory(src/plugins) 9 | endif() 10 | add_subdirectory(includeos) 11 | -------------------------------------------------------------------------------- /src/musl/sysinfo.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_sysinfo(struct sysinfo */*info*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_sysinfo(struct sysinfo *info) { 11 | return strace(sys_sysinfo, "sysinfo", info); 12 | } 13 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/plugin2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int my_plugin_functions; 4 | int f2_data = 0; 5 | 6 | __attribute__((constructor)) 7 | static void func2(){ 8 | INFO("Plugin 2","initialization function 2"); 9 | f2_data = 0xf2; 10 | my_plugin_functions++; 11 | } 12 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd_dhclient_linux/README.md: -------------------------------------------------------------------------------- 1 | # Test IncludeOS DHCP server with Linux dhclient 2 | 3 | Note: 4 | Works on a linux distributions that have dhclient and route. 5 | $INCLUDEOS_PREFIX/includeos/scripts/create_bridge.sh must be run prior to the test. 6 | 7 | Run test: sudo -E ./test.py 8 | -------------------------------------------------------------------------------- /test/userspace/microlb/run_cgroup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | CGR=myGroup 3 | # create cgroup 4 | cgcreate -g memory:/$CGR 5 | # 40 MB memory limit 6 | echo $(( 40 * 1024 * 1024 )) > /sys/fs/cgroup/memory/$CGR/memory.limit_in_bytes 7 | # disable OOM killer 8 | echo 1 > /sys/fs/cgroup/memory/$CGR/memory.oom_control 9 | -------------------------------------------------------------------------------- /src/util/pmr_default.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | std::pmr::memory_resource* std::pmr::get_default_resource() noexcept { 5 | static os::mem::Default_pmr* default_pmr; 6 | if (default_pmr == nullptr) 7 | default_pmr = new os::mem::Default_pmr{}; 8 | return default_pmr; 9 | } 10 | -------------------------------------------------------------------------------- /test/stress/net/README.md: -------------------------------------------------------------------------------- 1 | # Do some simple stress tests 2 | 3 | Systems being tested: 4 | 5 | * ICMP, using ping-flooding (`ping -f ...`) 6 | * UDP, using manual UDP package flooding 7 | * TCP, using `httperf` 8 | 9 | Sucess: test.py exits with status 0 10 | Fail: test.py exits with another status 11 | -------------------------------------------------------------------------------- /example/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void Service::start(const std::string& args){ 5 | printf("Args = %s\n", args.c_str()); 6 | printf("Try giving the service less memory, eg. 10MB in vm.json\n"); 7 | printf("Service done. Shutting down...\n"); 8 | os::shutdown(); 9 | } 10 | -------------------------------------------------------------------------------- /test/userspace/fuzz/apply_payloads.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=clang-7.0 4 | export CXX=clang++-7.0 5 | #RUN=OFF $INCLUDEOS_PREFIX/bin/lxp-run 6 | pushd build 7 | cmake .. -DSANITIZE=ON -DLIBFUZZER=OFF -DPAYLOAD_MODE=ON 8 | make -j4 9 | popd 10 | BINARY=build/"`cat build/binary.txt`" 11 | $BINARY 12 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/README.md: -------------------------------------------------------------------------------- 1 | # Test booting with GRUB 2 | 3 | The test will create a disk image with a GRUB bootloader and a minimal IncludeOS service. The test only verifies that the service boots with GRUB and starts successfully. 4 | 5 | NOTE: 6 | - Requires xorriso package 7 | - Requires grub-pc package 8 | -------------------------------------------------------------------------------- /src/musl/msync.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static long sys_msync(void */*addr*/, size_t /*length*/, int /*flags*/) 4 | { 5 | return -ENOSYS; 6 | } 7 | 8 | extern "C" 9 | long syscall_SYS_msync(void *addr, size_t length, int flags) 10 | { 11 | return strace(sys_msync, "msync", addr, length, flags); 12 | } 13 | -------------------------------------------------------------------------------- /test/integration/kernel/tls/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | 6 | from vmrunner import vmrunner 7 | if len(sys.argv) > 1: 8 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 9 | else: 10 | vmrunner.vms[0].boot(20,image_name='kernel_tls.elf.bin') 11 | -------------------------------------------------------------------------------- /test/integration/net/vlan/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | if len(sys.argv) > 1: 9 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 10 | else: 11 | vmrunner.vms[0].boot(20,image_name='net_vlan.elf.bin') 12 | -------------------------------------------------------------------------------- /test/userspace/fuzz/continous_fuzz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export CC=clang-6.0 4 | export CXX=clang++-6.0 5 | RUN=OFF $INCLUDEOS_PREFIX/bin/lxp-run 6 | BINARY=build/"`cat build/binary.txt`" 7 | # use -help=1 to see parameters to libfuzzer 8 | LD_LIBRARY_PATH=$HOME/llvm/install/lib $BINARY -max_len=120 -rss_limit_mb=512 9 | -------------------------------------------------------------------------------- /deps/botan/WIP.md: -------------------------------------------------------------------------------- 1 | # WIP build 2 | The current conanfile builds botan 3.4, which is the latest at the time of writing. 3 | __This is not yet tested with IncludeOS__. The last version known to work with IncludeOS is botan 2.8, which had explicit support. The approach now is to see if we can avoid requiring special support and use a linux build. -------------------------------------------------------------------------------- /src/musl/setpgid.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | long sys_setpgid(pid_t /*pid*/, gid_t /*gid*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_setpgid(pid_t pid, gid_t gid) 12 | { 13 | return strace(sys_setpgid, "setpgid", pid, gid); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/kernel/fiber/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | if len(sys.argv) > 1: 10 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 11 | else: 12 | vmrunner.vms[0].boot(image_name='kernel_fiber.elf.bin') 13 | -------------------------------------------------------------------------------- /test/integration/kernel/rng/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | if len(sys.argv) > 1: 10 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 11 | else: 12 | vmrunner.vms[0].boot(20,image_name='kernel_rng.elf.bin') 13 | -------------------------------------------------------------------------------- /CONTRIBUTE.md: -------------------------------------------------------------------------------- 1 | # Contributing to IncludeOS 2 | 3 | You're very welcome to [clone, edit and send pull-request](https://help.github.com/articles/using-pull-requests). 4 | 5 | **Please read the contribution guidelines: [Contributing to IncludeOS](http://includeos.readthedocs.io/en/latest/Contributing-to-IncludeOS.html)** 6 | 7 | ## Thank you! 8 | -------------------------------------------------------------------------------- /api/detail/os.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | inline uint64_t os::cycles_since_boot() noexcept 7 | { 8 | return os::Arch::cpu_cycles(); 9 | } 10 | inline uint64_t os::nanos_since_boot() noexcept 11 | { 12 | return (cycles_since_boot() * 1e6) / os::cpu_freq().count(); 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | 6 | from vmrunner import vmrunner 7 | if len(sys.argv) > 1: 8 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 9 | else: 10 | vmrunner.vms[0].boot(60,image_name='kernel_plugin_init.elf.bin') 11 | -------------------------------------------------------------------------------- /test/integration/net/bufstore/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | if len(sys.argv) > 1: 10 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 11 | else: 12 | vmrunner.vms[0].boot(30,image_name='net_bufstore.elf.bin') 13 | -------------------------------------------------------------------------------- /src/musl/fchown.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_fchown(int /*fd*/, uid_t /*owner*/, gid_t /*group*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_fchown(int fd, uid_t owner, gid_t group) 11 | { 12 | return strace(sys_fchown, "fchown", fd, owner, group); 13 | } 14 | -------------------------------------------------------------------------------- /src/musl/getrlimit.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | #include 4 | 5 | static int sys_getrlimit(int /*resource*/, struct rlimit*) { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_getrlimit(int resource, struct rlimit *rlim) { 11 | return strace(sys_getrlimit, "getrlimit", resource, rlim); 12 | } 13 | -------------------------------------------------------------------------------- /src/platform/kvm/kvmclock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | struct KVM_clock 7 | { 8 | static void init(); 9 | static uint64_t system_time(); 10 | static timespec wall_clock(); 11 | static util::KHz get_tsc_khz(); 12 | static void deactivate(); 13 | }; 14 | -------------------------------------------------------------------------------- /test/integration/kernel/context/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | if len(sys.argv) > 1: 10 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 11 | else: 12 | vmrunner.vms[0].boot(20,image_name='kernel_context.elf.bin') 13 | -------------------------------------------------------------------------------- /test/integration/kernel/spinlocks/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import os 5 | 6 | from vmrunner import vmrunner 7 | 8 | vm = vmrunner.vms[0]; 9 | 10 | if len(sys.argv) > 1: 11 | vm.boot(image_name=str(sys.argv[1])) 12 | else: 13 | # Build, run and clean 14 | vm.boot(image_name='kernel_spinlocks') 15 | -------------------------------------------------------------------------------- /src/musl/ftruncate.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_ftruncate(int /*fd*/, off_t /*length*/) 6 | { 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_ftruncate(int fd, off_t length) 12 | { 13 | return strace(sys_ftruncate, "ftruncate", fd, length); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/getrusage.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | #include 4 | 5 | static int sys_getrusage(int /*resource*/, struct rusage*) { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_getrusage(int resource, struct rusage *usage) { 11 | return strace(sys_getrusage, "getrusage", resource, usage); 12 | } 13 | -------------------------------------------------------------------------------- /src/arch/aarch64/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Branch according to exception level 3 | */ 4 | .macro execution_level_switch, var, el3, el2, el1 5 | mrs \var, CurrentEL 6 | cmp \var, 0xc 7 | b.eq \el3 8 | cmp \var, 0x8 9 | b.eq \el2 10 | cmp \var, 0x4 11 | b.eq \el1 12 | .endm 13 | -------------------------------------------------------------------------------- /src/musl/rmdir.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_rmdir(const char* /*pathname*/) 5 | { 6 | /* technically path needs to be verified first */ 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_rmdir(const char *pathname) 12 | { 13 | return strace(sys_rmdir, "rmdir", pathname); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/setrlimit.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | long sys_setrlimit(int /*resource*/, const struct rlimit* /*rlim*/) 4 | { 5 | return -ENOSYS; 6 | } 7 | 8 | extern "C" 9 | long syscall_SYS_setrlimit(int resource, 10 | const struct rlimit* rlim) 11 | { 12 | return strace(sys_setrlimit, "setrlimit", resource, rlim); 13 | } 14 | -------------------------------------------------------------------------------- /src/musl/chown.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_chown(const char* /*path*/, uid_t /*owner*/, gid_t /*group*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_chown(const char *path, uid_t owner, gid_t group) 11 | { 12 | return strace(sys_chown, "chown", path, owner, group); 13 | } 14 | -------------------------------------------------------------------------------- /src/musl/mprotect.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_mprotect(void* /*addr*/, size_t /*len*/, int /*prot*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_mprotect(void *addr, size_t len, int prot) 11 | { 12 | return strace(sys_mprotect, "mprotect", addr, len, prot); 13 | } 14 | -------------------------------------------------------------------------------- /src/musl/unlink.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_unlink(const char* /*pathname*/) 5 | { 6 | /* technically path needs to be verified first */ 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_unlink(const char *pathname) 12 | { 13 | return strace(sys_unlink, "rmdir", pathname); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/net/nat/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | #TODO move timeout to ctest.. 9 | if len(sys.argv) > 1: 10 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 11 | else: 12 | vmrunner.vms[0].boot(30,image_name='net_nat.elf.bin') 13 | -------------------------------------------------------------------------------- /test/unit/util/config.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char _CONFIG_JSON_START_; 5 | char _CONFIG_JSON_END_; 6 | 7 | CASE("Test empty config") 8 | { 9 | auto& config = Config::get(); 10 | EXPECT(config.data() == &_CONFIG_JSON_START_); 11 | EXPECT(config.size() != 0); 12 | EXPECT(config.empty() == false); 13 | } 14 | -------------------------------------------------------------------------------- /src/musl/set_robust_list.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static long sys_set_robust_list(struct robust_list_head */*head*/, size_t /*len*/) 4 | { 5 | return -ENOSYS; 6 | } 7 | 8 | extern "C" 9 | long syscall_SYS_set_robust_list(struct robust_list_head *head, size_t len) { 10 | return strace(sys_set_robust_list, "set_robust_list", head, len); 11 | } 12 | -------------------------------------------------------------------------------- /src/musl/sync.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | 3 | static long sys_sync() { 4 | return 0; 5 | } 6 | 7 | static long sys_syncfs() { 8 | return 0; 9 | } 10 | 11 | extern "C" { 12 | long syscall_SYS_sync() { 13 | return stubtrace(sys_sync, "sync"); 14 | } 15 | 16 | long syscall_SYS_syncfs() { 17 | return stubtrace(sys_syncfs, "syncfs"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/integration/kernel/block/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | 6 | 7 | from subprocess import call 8 | 9 | from vmrunner import vmrunner 10 | if len(sys.argv) > 1: 11 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 12 | else: 13 | vmrunner.vms[0].boot(40,image_name='kernel_block.elf.bin') 14 | -------------------------------------------------------------------------------- /test/integration/net/configure/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | #TODO move timeout to ctest.. 9 | if len(sys.argv) > 1: 10 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 11 | else: 12 | vmrunner.vms[0].boot(30,image_name='net_configure.elf.bin') 13 | -------------------------------------------------------------------------------- /test/integration/stl/stl/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | 6 | from vmrunner import vmrunner 7 | vm=vmrunner.vms[0] 8 | 9 | if len(sys.argv) > 1: 10 | vm.boot(image_name=str(sys.argv[1])) 11 | else: 12 | #the corutines is set in the CMakelists. 13 | vm.boot(40,image_name='stl_stl.elf.bin') 14 | -------------------------------------------------------------------------------- /misc/linux/lxp-pgo: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e 3 | echo -e "\n>>> Running service with profile-guided optimizations" 4 | source lxp-run -DPGO_ENABLE=ON -DPGO_GENERATE=ON 5 | # TODO: figure out if we are using clang or gcc as this is only for clang 6 | #llvm-profdata merge -output build/default.profdata build/default.profraw 7 | source lxp-run -DPGO_ENABLE=ON -DPGO_GENERATE=OFF 8 | -------------------------------------------------------------------------------- /src/musl/fchmod.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_fchmod(int /*fd*/, mode_t /*mode*/) { 5 | // currently makes no sense, especially since we're read-only 6 | return -EROFS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_fchmod(int fildes, mode_t mode) { 11 | return strace(sys_fchmod, "fchmod", fildes, mode); 12 | } 13 | -------------------------------------------------------------------------------- /src/platform/aarch64_vm/init_libc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace aarch64 5 | { 6 | extern void init_libc(uintptr_t dtb); 7 | } 8 | 9 | extern "C" { 10 | void kernel_sanity_checks(); 11 | uintptr_t __syscall_entry(); 12 | } 13 | 14 | #define LL_ASSERT(X) if (!(X)) { kprint("Early assertion failed: " #X "\n"); asm("hlt 0xf000"); } 15 | -------------------------------------------------------------------------------- /test/integration/net/gateway/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_gateway.img", 3 | "net" : [ 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 5 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2f"}, 6 | {"device" : "vmxnet3", "mac" : "c0:01:0a:00:00:20"}, 7 | {"device" : "vmxnet3", "mac" : "c0:01:0a:00:00:23"} 8 | ], 9 | "mem" : 128 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "drives" : [ 3 | { 4 | "file" : "virtio1.disk", 5 | "type" : "virtio", 6 | "format" : "raw", 7 | "media" : "disk" 8 | }, 9 | { 10 | "file" : "virtio2.disk", 11 | "type" : "virtio", 12 | "format" : "raw", 13 | "media" : "disk" 14 | }], 15 | "intrusive": "True" 16 | } 17 | -------------------------------------------------------------------------------- /src/musl/chmod.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_chmod(const char* /*path*/, mode_t /*mode*/) { 5 | // currently makes no sense, especially since we're read-only 6 | return -EROFS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_chmod(const char *path, mode_t mode) { 11 | return strace(sys_chmod, "chmod", path, mode); 12 | } 13 | -------------------------------------------------------------------------------- /src/musl/mkdir.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_mkdir(const char* /*path*/, mode_t /*mode*/) { 5 | // currently makes no sense, especially since we're read-only 6 | return -EROFS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_mkdir(const char *path, mode_t mode) { 11 | return strace(sys_mkdir, "mkdir", path, mode); 12 | } 13 | -------------------------------------------------------------------------------- /src/platform/x86_pc/init_libc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace x86 5 | { 6 | extern void init_libc(uint32_t magic, uint32_t address); 7 | } 8 | 9 | extern "C" { 10 | void kernel_sanity_checks(); 11 | uintptr_t __syscall_entry(); 12 | } 13 | 14 | #define LL_ASSERT(X) if (!(X)) { kprint("Early assertion failed: " #X "\n"); asm("cli;hlt"); } 15 | -------------------------------------------------------------------------------- /test/integration/stl/crt/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | vm=vmrunner.vms[0] 9 | 10 | 11 | if len(sys.argv) > 1: 12 | vm.boot(image_name=str(sys.argv[1])) 13 | else: 14 | #the corutines is set in the CMakelists. 15 | vm.boot(40,image_name='stl_crt.elf.bin') 16 | -------------------------------------------------------------------------------- /test/integration/net/nat/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2f"}, 5 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:20"}, 6 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:23"}, 7 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:24"} 8 | ], 9 | "mem" : 128 10 | } 11 | -------------------------------------------------------------------------------- /test/integration/posix/utsname/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | vm = vmrunner.vms[0] 9 | 10 | # Boot the VM, taking a timeout as parameter 11 | if len(sys.argv) > 1: 12 | vm.boot(image_name=str(sys.argv[1])) 13 | else: 14 | vm.boot(10,image_name='posix_utsname.elf.bin') 15 | -------------------------------------------------------------------------------- /test/integration/util/tar/tar_example/l1_f1/l2/README.md: -------------------------------------------------------------------------------- 1 | ### IncludeOS Demo Service 2 | 3 | ``` 4 | make 5 | ./run.sh 6 | ``` 7 | 8 | This demo-service should start an instance of IncludeOS that brings up a minimal web service on port 80 with static content. 9 | Note: Remember to run the bridge creation script for networking to work on qemu (by running `etc/create_bridge.sh`). 10 | -------------------------------------------------------------------------------- /test/integration/util/tar_gz/tar_example/l1_f1/l2/README.md: -------------------------------------------------------------------------------- 1 | ### IncludeOS Demo Service 2 | 3 | ``` 4 | make 5 | ./run.sh 6 | ``` 7 | 8 | This demo-service should start an instance of IncludeOS that brings up a minimal web service on port 80 with static content. 9 | Note: Remember to run the bridge creation script for networking to work on qemu (by running `etc/create_bridge.sh`). 10 | -------------------------------------------------------------------------------- /src/musl/creat.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | #include 3 | 4 | static long sys_creat(const char* /*pathname*/, mode_t /*mode*/) { 5 | // currently makes no sense, especially since we're read-only 6 | return -EROFS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_creat(const char *pathname, mode_t mode) { 11 | return stubtrace(sys_creat, "creat", pathname, mode); 12 | } 13 | -------------------------------------------------------------------------------- /src/musl/gettid.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | 3 | static long sys_gettid() { 4 | // TODO: threading partially implemented. Needs cleaning up. 5 | // We used to warn: 6 | // "gettid not implemented for threaded IncludeOS" 7 | // But we want to enable -Werror 8 | return 1; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_gettid() { 13 | return stubtrace(sys_gettid, "gettid"); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/fs/memdisk/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from subprocess import call 8 | 9 | from vmrunner import vmrunner 10 | vm = vmrunner.vms[0] 11 | 12 | #boot the vm 13 | if len(sys.argv) > 1: 14 | vm.boot(20,image_name=str(sys.argv[1])) 15 | else: 16 | vm.boot(20,image_name='fs_memdisk.elf.bin') 17 | -------------------------------------------------------------------------------- /test/integration/mod/gsl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(mod_gsl "GSL test" ${SOURCES}) 12 | os_add_stdout(mod_gsl default_stdout) 13 | 14 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/userspace/s2n/serial.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace s2n 4 | { 5 | using Stream_ptr = std::unique_ptr; 6 | 7 | extern void serial_test(const std::string&, const std::string&); 8 | extern s2n_config* serial_create_config(); 9 | extern s2n_config* serial_get_config(); 10 | extern void serial_free_config(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /misc/linux/lxp-callgraph: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e 3 | 4 | echo -e "\n>>> Installing dependencies" 5 | sudo pip install setuptools wheel 6 | pip -q install gprof2dot 7 | sudo apt install -y graphviz 8 | 9 | BINARY="`cat build/binary.txt`" 10 | echo -e "\n>>> Generating callgraph.svg from $BINARY" 11 | gprof build/$BINARY | gprof2dot | dot -Tsvg -o callgraph.svg 12 | firefox callgraph.svg 13 | -------------------------------------------------------------------------------- /src/musl/readlink.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_readlink(const char* /*path*/, char* /*buf*/, size_t /*bufsiz*/) 6 | { 7 | return -EIO; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_readlink(const char *path, char *buf, size_t bufsiz) 12 | { 13 | return strace(sys_readlink, "readlink", path, buf, bufsiz); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/kernel/grub/grubiso.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | LOCAL_DISK="$(mktemp -d)" 5 | SERVICE=$1 6 | GRUBIMG=grub.iso 7 | 8 | echo "Building $GRUBIMG..." 9 | # create grub.iso 10 | mkdir -p "$LOCAL_DISK"/boot/grub 11 | cp "$SERVICE" "$LOCAL_DISK"/boot/service 12 | cp grub.cfg "$LOCAL_DISK"/boot/grub 13 | grub-mkrescue -o "$GRUBIMG" "$LOCAL_DISK" 14 | rm -vrf "$LOCAL_DISK" 15 | -------------------------------------------------------------------------------- /test/integration/fs/fat16/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import os 5 | from subprocess import call 6 | from vmrunner import vmrunner 7 | 8 | # Get an auto-created VM from the vmrunner 9 | vm = vmrunner.vms[0] 10 | 11 | # Boot the VM 12 | if len(sys.argv) > 1: 13 | vm.boot(30,image_name='fs_fat16.elf.bin') 14 | else: 15 | vm.boot(30,image_name='fs_fat16.elf.bin') 16 | -------------------------------------------------------------------------------- /test/integration/fs/virtio_block/image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e #stop on first error 3 | echo "Creating *huge* disk for test" 4 | truncate -s 4000000000 image.img 5 | sudo mkfs.fat image.img 6 | 7 | mkdir -p mountpoint 8 | sudo mount -o rw,sync image.img mountpoint 9 | 10 | sudo cp service.cpp mountpoint/ 11 | sudo sync 12 | sudo umount mountpoint 13 | sudo rm -rf mountpoint 14 | echo "Done" 15 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "image" : "test_dhcp_server.img", 3 | "net" : [{"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2f"}, 5 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:20"}, 6 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:23"}], 7 | "mem" : 128, 8 | "time_sensitive" : "True" 9 | } 10 | -------------------------------------------------------------------------------- /test/integration/stl/crt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(stl_crt "C/C++ runtime test" ${SOURCES}) 12 | os_add_stdout(stl_crt default_stdout) 13 | 14 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /userspace/src/profile.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void StackSampler::begin() {} 4 | uint64_t StackSampler::samples_total() noexcept { 5 | return 1; 6 | } 7 | uint64_t StackSampler::samples_asleep() noexcept { 8 | return 0; 9 | } 10 | void StackSampler::print(int) {} 11 | void StackSampler::set_mode(mode_t) {} 12 | 13 | std::string HeapDiag::to_string() 14 | { 15 | return ""; 16 | } 17 | -------------------------------------------------------------------------------- /src/musl/umask.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | mode_t THE_MASK = 002; 5 | 6 | static mode_t sys_umask(mode_t cmask) { 7 | mode_t prev_mask = THE_MASK; 8 | 9 | if(THE_MASK != cmask) 10 | THE_MASK = cmask; 11 | 12 | return prev_mask; 13 | } 14 | 15 | extern "C" 16 | mode_t syscall_SYS_umask(mode_t cmask) { 17 | return strace(sys_umask, "umask", cmask); 18 | } 19 | -------------------------------------------------------------------------------- /test/integration/net/gateway/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | #if name is passed execute that do not clean and do not rebuild.. 10 | if len(sys.argv) > 1: 11 | vmrunner.vms[0].boot(image_name=str(sys.argv[1])) 12 | else: 13 | vmrunner.vms[0].boot(70,image_name='net_gateway.elf.bin') 14 | -------------------------------------------------------------------------------- /test/integration/stl/exceptions/README.md: -------------------------------------------------------------------------------- 1 | # Test exceptions 2 | 3 | Exceptions are usually taken for granted, but they require proper unwinding, which is not itself a part of the standard C++ library. 4 | 5 | These tests are internal only, so just running `test.sh` should be enough, and the output will be self explanatory. 6 | 7 | Sucess: Outputs SUCCESS if all tests pass 8 | Fail: Panic if any test fails 9 | -------------------------------------------------------------------------------- /src/musl/openat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_openat(int /*dirfd*/, const char* /*path*/, int /*flags*/, mode_t) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_openat(int dirfd, const char *pathname, int flags, mode_t mode) { 12 | return strace(sys_openat, "openat", dirfd, pathname, flags, mode); 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/net/slaac/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (test_slaac) 5 | include(os) 6 | 7 | os_add_executable(net_slaac "IncludeOS Slaac test" service.cpp) 8 | 9 | os_add_drivers(net_slaac virtionet) 10 | os_add_stdout(net_slaac default_stdout) 11 | 12 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 13 | -------------------------------------------------------------------------------- /test/integration/posix/pthread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(pthread_test "pthread test" ${SOURCES}) 12 | os_add_stdout(pthread_test default_stdout) 13 | 14 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/stress/net/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(stress "Stress test" ${SOURCES}) 12 | os_add_stdout(stress default_stdout) 13 | os_add_drivers(stress virtionet) 14 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /src/musl/close.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_close(int fd) 5 | { 6 | if(auto* fildes = FD_map::_get(fd); fildes) 7 | { 8 | long res = fildes->close(); 9 | FD_map::close(fd); 10 | return res; 11 | } 12 | return -EBADF; 13 | } 14 | 15 | extern "C" 16 | long syscall_SYS_close(int fd) { 17 | return strace(sys_close, "close", fd); 18 | } 19 | -------------------------------------------------------------------------------- /src/musl/sigaltstack.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_sigaltstack(const stack_t * /*ss*/, stack_t * /*old_ss*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_sigaltstack(const stack_t *_Nullable ss, 11 | stack_t *_Nullable old_ss) 12 | { 13 | return strace(sys_sigaltstack, "sigaltstack", ss, old_ss); 14 | } 15 | -------------------------------------------------------------------------------- /src/platform/x86_pc/boot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_custom_command( 3 | OUTPUT bootloader 4 | COMMAND ${CMAKE_ASM_NASM_COMPILER} -f bin -I${CMAKE_CURRENT_SOURCE_DIR}/../ -o bootloader ${CMAKE_CURRENT_SOURCE_DIR}/bootloader.asm 5 | DEPENDS bootloader.asm disk_read_lba.asm 6 | ) 7 | 8 | add_custom_target(run ALL DEPENDS bootloader) 9 | 10 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bootloader DESTINATION boot) 11 | -------------------------------------------------------------------------------- /test/integration/kernel/kprint/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(kernel_kprint "kprint() test" ${SOURCES}) 12 | os_add_stdout(kernel_kprint default_stdout) 13 | 14 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/integration/net/udp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | os_add_executable(net_udp "UDP test" service.cpp) 8 | 9 | os_add_drivers(net_udp virtionet ip4_reassembly boot_logger) 10 | os_add_stdout(net_udp default_stdout) 11 | 12 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 13 | -------------------------------------------------------------------------------- /src/arch/i686/arch_musl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | long syscall_SYS_set_thread_area(struct user_desc *u_info) 6 | { 7 | os::panic("Libc not supported for 32 bit currently!"); 8 | return -ENOSYS; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_arch_prctl(int code, uintptr_t ptr) { 13 | os::panic("Libc not supported for 32 bit currently!"); 14 | return -ENOSYS; 15 | } 16 | -------------------------------------------------------------------------------- /src/musl/execve.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_execve(const char*, char *const[], char *const[]) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_execve(const char *filename, char *const argv[], 12 | char *const envp[]) 13 | { 14 | return strace(sys_execve, "execve", filename, argv, envp); 15 | } 16 | -------------------------------------------------------------------------------- /src/musl/getrandom.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | // TODO: flags are ignored. 5 | static long sys_getrandom(void* buf, size_t len, unsigned int flags) 6 | { 7 | rng_absorb(buf, len); 8 | return len; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_getrandom(void *buf, size_t len, unsigned int flags) { 13 | return strace(sys_getrandom, "getrandom", buf, len, flags); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/rename.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_rename(const char* /*oldpath*/, const char* /*newpath*/) 5 | { 6 | // currently makes no sense, especially since we're read-only 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_rename(const char* oldpath, const char* newpath) 12 | { 13 | return strace(sys_rename, "rename", oldpath, newpath); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/kernel/block/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(kernel_block "Kernel blocking test" ${SOURCES}) 12 | os_add_stdout(kernel_block default_stdout) 13 | 14 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/integration/net/bufstore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_bufstore "Bufferstore test" ${SOURCES}) 12 | 13 | os_add_stdout(net_bufstore default_stdout) 14 | 15 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 16 | -------------------------------------------------------------------------------- /test/integration/stl/coroutines/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(stl_coroutines "C++ coroutines test" ${SOURCES}) 12 | os_add_stdout(stl_coroutines default_stdout) 13 | 14 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /src/arch/aarch64/arch_musl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "cpu.hpp" 4 | 5 | extern "C" 6 | long syscall_SYS_set_thread_area(struct user_desc *u_desc) { 7 | set_tpidr(u_info); // This probably still does not work 8 | return 0; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_arch_prctl(int code, uintptr_t ptr) { 13 | os::panic("Arch_prctl is specific to x86!"); 14 | return -ENOSYS; 15 | } 16 | -------------------------------------------------------------------------------- /src/crt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(SRCS 2 | c_abi.c 3 | ctype_b_loc.c 4 | ctype_tolower_loc.c 5 | quick_exit.cpp 6 | cxx_abi.cpp 7 | ) 8 | add_library(crt OBJECT ${SRCS}) 9 | 10 | # disable sanitizers on c_abi and cxx_abi, etc. 11 | set_source_files_properties(c_abi.c PROPERTIES COMPILE_FLAGS "-fno-sanitize=all") 12 | set_source_files_properties(cxx_abi.cpp PROPERTIES COMPILE_FLAGS "-fno-sanitize=all") 13 | -------------------------------------------------------------------------------- /src/musl/mknod.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_mknod(const char* /*pathname*/, mode_t /*mode*/, dev_t /*dev*/) 5 | { 6 | // currently makes no sense, especially since we're read-only 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_mknod(const char *pathname, mode_t mode, dev_t dev) { 12 | return strace(sys_mknod, "mknod", pathname, mode, dev); 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/fs/memdisk/bigdisk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### BIG DISK CREATION ### 4 | DISK=big.disk 5 | MOUNTDIR=tmpdisk 6 | 7 | rm -f $DISK 8 | echo "> Creating big disk" 9 | fallocate -l 131072000 $DISK # 256000 sectors 10 | mkfs.fat $DISK 11 | # mkdir -p $MOUNTDIR 12 | # sudo mount $DISK $MOUNTDIR 13 | # sudo cp banana.txt $MOUNTDIR 14 | # sync # Mui Importante 15 | # sudo umount $MOUNTDIR 16 | # rmdir $MOUNTDIR 17 | -------------------------------------------------------------------------------- /test/integration/kernel/context/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(kernel_context "Task switching test" ${SOURCES}) 12 | os_add_stdout(kernel_context default_stdout) 13 | 14 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/integration/kernel/timers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(kernel_timers "Timers Test Service" service.cpp timers.cpp) 12 | os_add_stdout(kernel_timers default_stdout) 13 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 14 | -------------------------------------------------------------------------------- /test/integration/net/http/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_http "HTTP test" ${SOURCES}) 12 | os_add_drivers(net_http virtionet) 13 | os_add_stdout(net_http default_stdout) 14 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/integration/stl/stl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(stl_stl "C++ STL test" ${SOURCES}) 12 | os_add_stdout(stl_stl default_stdout) 13 | 14 | os_add_plugins(stl_stl vfs) 15 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 16 | -------------------------------------------------------------------------------- /src/musl/munmap.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | extern "C" void kfree(void* addr, size_t length); 4 | 5 | static long sys_munmap(void *addr, size_t length) 6 | { 7 | if(UNLIKELY(length == 0)) 8 | return -EINVAL; 9 | 10 | kfree(addr, length); 11 | return 0; 12 | } 13 | 14 | extern "C" 15 | long syscall_SYS_munmap(void *addr, size_t length) 16 | { 17 | return strace(sys_munmap, "munmap", addr, length); 18 | } 19 | -------------------------------------------------------------------------------- /vmbuild.nix: -------------------------------------------------------------------------------- 1 | { nixpkgs ? ./pinned.nix, 2 | pkgs ? import nixpkgs { config = { }; overlays = [ ]; }, 3 | }: 4 | 5 | pkgs.stdenv.mkDerivation rec { 6 | pname = "vmbuild"; 7 | version = "dev"; 8 | 9 | sourceRoot = pname; 10 | 11 | srcs = [ 12 | ./vmbuild 13 | ./src 14 | ./api 15 | ]; 16 | 17 | nativeBuildInputs = [ 18 | pkgs.buildPackages.cmake 19 | pkgs.buildPackages.nasm 20 | ]; 21 | } 22 | -------------------------------------------------------------------------------- /api/pmr: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if __has_include() 4 | #include 5 | #include 6 | #else 7 | #include 8 | #include 9 | namespace std { 10 | namespace pmr = std::experimental::pmr; 11 | } 12 | #endif 13 | 14 | namespace os::mem { 15 | using buffer = std::pmr::vector; 16 | using buf_ptr = std::shared_ptr; 17 | } 18 | -------------------------------------------------------------------------------- /src/musl/mkdirat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_mkdirat(int /*fd*/, const char* /*path*/, mode_t /*mode*/) { 6 | // currently makes no sense, especially since we're read-only 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_mkdirat(int fd, const char *path, mode_t mode) { 12 | return strace(sys_mkdirat, "mkdirat", fd, path, mode); 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/posix/conf/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | # Get an auto-created VM from the vmrunner 10 | vm = vmrunner.vms[0] 11 | 12 | # Boot the VM, taking a timeout as parameter 13 | if len(sys.argv) > 1: 14 | vm.boot(20,image_name=str(sys.argv[1])) 15 | else: 16 | vm.boot(20,image_name='posix_conf.elf.bin') 17 | -------------------------------------------------------------------------------- /src/musl/mincore.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static long sys_mincore([[maybe_unused]]void *addr, 4 | [[maybe_unused]]size_t length, 5 | [[maybe_unused]]unsigned char *vec) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_mincore(void *addr, size_t length, unsigned char *vec) 12 | { 13 | return strace(sys_mincore, "mincore", addr, length, vec); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/fs/ide/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(fs_ide "IDE driver test" ${SOURCES}) 12 | os_add_stdout(fs_ide default_stdout) 13 | 14 | os_add_drivers(fs_ide ide_readonly) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/mod/gsl/README.md: -------------------------------------------------------------------------------- 1 | # Test basics of C++ Core Guidelines Support Library 2 | This just tests a fraction of GSL functionality, but it's here to just verify that basic GSL support is in place and working in IncludeOS. 3 | 4 | Sucess: Outputs SUCCESS if all tests pass 5 | Fail: Panic if any test fails 6 | 7 | NOTE: This test uses the `lest` unit test framework as well for some tests. The result of those tests will also be reported. 8 | -------------------------------------------------------------------------------- /test/integration/net/nat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_nat "NAT test" ${SOURCES}) 12 | 13 | os_add_drivers(net_nat virtionet) 14 | os_add_stdout(net_nat default_stdout) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/net/icmp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_icmp "ICMP test" ${SOURCES}) 12 | 13 | os_add_drivers(net_icmp virtionet) 14 | os_add_stdout(net_icmp default_stdout) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /src/musl/mknodat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_mknodat(int /*dirfd*/, const char* /*path*/, mode_t, dev_t) 5 | { 6 | // currently makes no sense, especially since we're read-only 7 | return -EROFS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev) { 12 | return strace(sys_mknodat, "mknodat", dirfd, pathname, mode, dev); 13 | } 14 | -------------------------------------------------------------------------------- /test/integration/net/dns/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_dns "DNS test" ${SOURCES}) 12 | 13 | os_add_drivers(net_dns virtionet e1000 vmxnet3) 14 | os_add_stdout(net_dns default_stdout) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/net/tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_tcp "TCP test" ${SOURCES}) 12 | 13 | os_add_drivers(net_tcp virtionet e1000 vmxnet3) 14 | os_add_stdout(net_tcp default_stdout) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | os_add_executable(net_dhcpd "IncludeOS DHCP server test" service.cpp) 8 | 9 | os_add_plugins(net_dhcpd autoconf) 10 | os_add_drivers(net_dhcpd virtionet) 11 | os_add_stdout(net_dhcpd default_stdout) 12 | 13 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 14 | -------------------------------------------------------------------------------- /test/integration/kernel/exception/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | set(ELF_SYMBOLS true) 5 | 6 | project (service) 7 | include(os) 8 | 9 | set(SOURCES 10 | service.cpp 11 | ) 12 | 13 | os_add_executable(kernel_exception "CPU exception test" ${SOURCES}) 14 | os_add_stdout(kernel_exception default_stdout) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/net/dhclient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | os_add_executable(net_dhclient "IncludeOS DHCP test" service.cpp) 8 | 9 | os_add_plugins(net_dhclient autoconf) 10 | os_add_drivers(net_dhclient virtionet) 11 | os_add_stdout(net_dhclient default_stdout) 12 | 13 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 14 | -------------------------------------------------------------------------------- /deps/botan/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs 3 | }: 4 | let 5 | cpuFlag = if pkgs.stdenv.system == "i686-linux" then "x86_32" else "x86_64"; 6 | in 7 | pkgs.botan2.overrideAttrs (oldAttrs: { 8 | 9 | postInstall = (oldAttrs.postInstall or "") + '' 10 | ln -sr "$out/include/botan-2/botan" "$out/include" 11 | ''; 12 | 13 | buildPhase = '' 14 | runHook preBuild 15 | 16 | make -j $NIX_BUILD_CORES 17 | 18 | runHook postBuild 19 | ''; 20 | }) 21 | -------------------------------------------------------------------------------- /src/musl/faccessat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_faccessat(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/) 6 | { 7 | // TODO Same as access(), but path is relative to fd 8 | return -EROFS; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_faccessat(int fd, const char *path, mode_t mode, int flag) { 13 | return strace(sys_faccessat, "faccessat", fd, path, mode, flag); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/fchmodat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_fchmodat(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/) 6 | { 7 | // currently makes no sense, especially since we're read-only 8 | return -EROFS; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_fchmodat(int fd, const char *path, mode_t mode, int flag) { 13 | return strace(sys_fchmodat, "fchmodat", fd, path, mode, flag); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/readv.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | #include 4 | 5 | static ssize_t sys_readv(int fd, const struct iovec* iov, int iovcnt) 6 | { 7 | if(auto* fildes = FD_map::_get(fd); fildes) 8 | return fildes->readv(iov, iovcnt); 9 | 10 | return -EBADF; 11 | } 12 | 13 | extern "C" 14 | ssize_t syscall_SYS_readv(int fd, const struct iovec *iov, int iovcnt) 15 | { 16 | return strace(sys_readv, "readv", fd, iov, iovcnt); 17 | } 18 | -------------------------------------------------------------------------------- /test/integration/fs/ide_write/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(fs_ide_write "VFS filesystem test" ${SOURCES}) 12 | os_add_stdout(fs_ide_write default_stdout) 13 | os_add_drivers(fs_ide_write ide_writeonly) 14 | 15 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 16 | -------------------------------------------------------------------------------- /test/integration/stl/exceptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(stl_exceptions "C++ exceptions test" ${SOURCES}) 12 | os_add_stdout(stl_exceptions default_stdout) 13 | os_add_drivers(stl_exceptions boot_logger) 14 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /src/musl/faccessat2.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_faccessat2(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/) 6 | { 7 | // TODO Same as access(), but path is relative to fd 8 | return -EROFS; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_faccessat2(int fd, const char *path, mode_t mode, int flag) { 13 | return strace(sys_faccessat2, "faccessat2", fd, path, mode, flag); 14 | } 15 | -------------------------------------------------------------------------------- /src/musl/fchmodat2.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_fchmodat2(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/) 6 | { 7 | // currently makes no sense, especially since we're read-only 8 | return -EROFS; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_fchmodat2(int fd, const char *path, mode_t mode, int flag) { 13 | return strace(sys_fchmodat2, "fchmodat2", fd, path, mode, flag); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/net/router6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | os_add_executable(net_router6 "Routing test ipv6" service.cpp) 8 | 9 | os_add_drivers(net_router6 virtionet) 10 | os_add_stdout(net_router6 default_stdout) 11 | 12 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 13 | configure_file(setup.sh ${CMAKE_CURRENT_BINARY_DIR}) 14 | -------------------------------------------------------------------------------- /src/musl/read.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_read(int fd, void* buf, size_t len) 5 | { 6 | if(UNLIKELY(buf == nullptr)) 7 | return -EFAULT; 8 | 9 | if(auto* fildes = FD_map::_get(fd); fildes) 10 | return fildes->read(buf, len); 11 | 12 | return -EBADF; 13 | } 14 | 15 | extern "C" 16 | long syscall_SYS_read(int fd, void *buf, size_t nbyte) { 17 | return strace(sys_read, "read", fd, buf, nbyte); 18 | } 19 | -------------------------------------------------------------------------------- /src/musl/wait4.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long 6 | sys_wait4(pid_t /*pid*/, int* /*wstatus*/, int /*options*/, 7 | struct rusage* /*rusage*/) 8 | { 9 | return 0; 10 | } 11 | 12 | extern "C" 13 | long syscall_SYS_wait4(pid_t pid, int *wstatus, int options, 14 | struct rusage *rusage) 15 | { 16 | return strace(sys_wait4, "wait4", pid, wstatus, options, rusage); 17 | } 18 | -------------------------------------------------------------------------------- /test/integration/net/websocket/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include (os) 6 | 7 | 8 | set(SOURCES 9 | service.cpp 10 | ) 11 | 12 | os_add_executable(net_websocket "Websocket test" ${SOURCES}) 13 | 14 | os_add_drivers(net_websocket virtionet) 15 | os_add_stdout(net_websocket default_stdout) 16 | 17 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /test/integration/plugin/unik/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | # TODO: Implement a mockup of the Unik registration protocol on 10.0.0.56 10 | 11 | vm=vmrunner.vms[0] 12 | 13 | if len(sys.argv) > 1: 14 | vm.boot(image_name=str(sys.argv[1])) 15 | else: 16 | # Boot the VM, taking a timeout as parameter 17 | vm.boot(60,image_name="plugin_unik.elf.bin") 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | draw_white_space = all 11 | trim_trailing_white_space_on_save = true 12 | 13 | [Makefile] 14 | indent_style = tab 15 | 16 | [Makelib] 17 | indent_style = tab 18 | 19 | [*.py] 20 | indent_size = 4 21 | 22 | [boot] 23 | indent_size = 4 24 | 25 | [*.asm] 26 | indent_size = 4 27 | -------------------------------------------------------------------------------- /src/musl/sched_setscheduler.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_sched_setscheduler(pid_t /*pid*/, int /*policy*/, const struct sched_param* /*param*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_sched_setscheduler(pid_t pid, int policy, 11 | const struct sched_param *param) 12 | { 13 | return strace(sys_sched_setscheduler, "sched_setscheduler", pid, policy, param); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/kernel/modules/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | set(ARCH i686) 5 | set(PLATFORM x86_nano) 6 | 7 | project (service) 8 | include(os) 9 | 10 | MESSAGE(STATUS "CMake root: " ${INCLUDEOS_PREFIX}) 11 | 12 | set(SOURCES 13 | service.cpp 14 | ) 15 | 16 | os_add_executable(kernel_modules "Kernel modules test" ${SOURCES}) 17 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /test/integration/kernel/term/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(kernel_term "Terminal test" ${SOURCES}) 12 | os_add_stdout(kernel_term default_stdout) 13 | os_add_drivers(kernel_term virtionet) 14 | #os_add_plugins(service vfs) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /src/musl/statx.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | long sys_statx(int /*dirfd*/, const char* /*pathname*/, int /*flags*/, 5 | unsigned int /*mask*/, struct statx* /*statxbuf*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_statx(int dirfd, const char *pathname, int flags, 12 | unsigned int mask, struct statx *statxbuf) { 13 | return strace(sys_statx, "statx", dirfd, pathname, flags, mask, statxbuf); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/net/tcp/stream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace net::tcp 5 | { 6 | /*#include // remove me, sack debugging 7 | std::ostream& operator<< (std::ostream& out, const net::tcp::sack::Entries& ent) { 8 | for (auto el : ent) { 9 | out << el << "\n"; 10 | } 11 | return out; 12 | }*/ 13 | 14 | int Stream::get_cpuid() const noexcept { 15 | return m_tcp->host().get_cpuid(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/integration/kernel/osinit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(osinit "OS initialization test" ${SOURCES}) 12 | os_add_stdout(osinit default_stdout) 13 | os_add_drivers(osinit boot_logger) 14 | os_add_plugins(osinit field_medic) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/kernel/tls/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | #option(threading "" ON) 4 | 5 | project (tls) 6 | include(os) 7 | 8 | set(SOURCES 9 | service.cpp # ...add more here 10 | ) 11 | 12 | os_add_executable(kernel_tls "TLS test" ${SOURCES}) 13 | os_add_stdout(kernel_tls default_stdout) 14 | os_add_drivers(kernel_tls boot_logger) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /src/musl/exit.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | #include 5 | 6 | __attribute__((noreturn)) 7 | static long sys_exit(int status) 8 | { 9 | const std::string msg = "Service exited with status " + std::to_string(status) + "\n"; 10 | os::print(msg.data(), msg.size()); 11 | __arch_poweroff(); 12 | __builtin_unreachable(); 13 | } 14 | 15 | extern "C" 16 | void syscall_SYS_exit(int status) { 17 | strace(sys_exit, "exit", status); 18 | } 19 | -------------------------------------------------------------------------------- /src/musl/set_tid_address.cpp: -------------------------------------------------------------------------------- 1 | #include "stub.hpp" 2 | 3 | static struct { 4 | int tid = 1; 5 | int* set_child_tid = nullptr; 6 | int* clear_child_tid = nullptr; 7 | } __main_thread__; 8 | 9 | static long sys_set_tid_address(int* tidptr) { 10 | __main_thread__.clear_child_tid = tidptr; 11 | return __main_thread__.tid; 12 | } 13 | 14 | extern "C" 15 | long syscall_SYS_set_tid_address(int* tidptr) { 16 | return stubtrace(sys_set_tid_address, "set_tid_address", tidptr); 17 | } 18 | -------------------------------------------------------------------------------- /test/integration/fs/memdisk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(memdisk) 5 | include(os) 6 | 7 | set(SOURCES 8 | twosector.cpp 9 | ) 10 | 11 | os_add_executable(fs_memdisk "Memdisk filesystem test" ${SOURCES}) 12 | os_add_stdout(fs_memdisk default_stdout) 13 | 14 | os_add_memdisk(fs_memdisk ${CMAKE_CURRENT_SOURCE_DIR}/sector2.disk) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /api/net/openssl/init.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace openssl 6 | { 7 | extern void setup_rng(); 8 | extern void verify_rng(); 9 | extern void init(); 10 | 11 | extern SSL_CTX* create_server(const std::string& cert, const std::string& key); 12 | 13 | extern SSL_CTX* create_client(fs::List, bool verify_peer = false); 14 | // enable peer certificate verification 15 | extern void client_verify_peer(SSL_CTX*); 16 | } 17 | -------------------------------------------------------------------------------- /src/musl/fcntl.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_fcntl(int fd, int cmd, va_list va) 5 | { 6 | if(auto* fildes = FD_map::_get(fd); fildes) 7 | return fildes->fcntl(cmd, va); 8 | 9 | return -EBADF; 10 | } 11 | 12 | extern "C" 13 | long syscall_SYS_fcntl(int fd, int cmd, ... /* arg */ ) 14 | { 15 | va_list va; 16 | va_start(va, cmd); 17 | auto ret = strace(sys_fcntl, "fcntl", fd, cmd, va); 18 | va_end(va); 19 | return ret; 20 | } 21 | -------------------------------------------------------------------------------- /test/integration/kernel/smp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (smp_test) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp # ...add more here 9 | ) 10 | 11 | os_add_executable(kernel_smp "SMP test" ${SOURCES}) 12 | os_add_stdout(kernel_smp default_stdout) 13 | os_add_drivers(kernel_smp boot_logger) 14 | #os_add_plugins(service vfs) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/kernel/spinlocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | set(ELF_SYMBOLS true) 4 | 5 | project (service) 6 | include(os) 7 | 8 | set(SOURCES 9 | service.cpp 10 | ) 11 | 12 | os_add_executable(kernel_spinlocks "spinlock test" ${SOURCES}) 13 | os_add_stdout(kernel_spinlocks default_stdout) 14 | os_add_drivers(kernel_spinlocks boot_logger) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/posix/utsname/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(posix_utsname "POSIX utsname test" ${SOURCES}) 14 | 15 | os_add_stdout(posix_utsname default_stdout) 16 | 17 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /src/musl/sched_getaffinity.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_sched_getaffinity(pid_t /*pid*/, size_t /*cpusetsize*/, 5 | cpu_set_t */*mask*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_sched_getaffinity(pid_t pid, size_t cpusetsize, 12 | cpu_set_t *mask) 13 | { 14 | return strace(sys_sched_getaffinity, "sched_getaffinity", pid, cpusetsize, mask); 15 | } 16 | -------------------------------------------------------------------------------- /src/musl/sched_setaffinity.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_sched_setaffinity(pid_t /*pid*/, size_t /*cpusetsize*/, 5 | cpu_set_t */*mask*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | 10 | extern "C" 11 | long syscall_SYS_sched_setaffinity(pid_t pid, size_t cpusetsize, 12 | cpu_set_t *mask) 13 | { 14 | return strace(sys_sched_setaffinity, "sched_setaffinity", pid, cpusetsize, mask); 15 | } 16 | -------------------------------------------------------------------------------- /test/integration/kernel/rng/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp # ...add more here 9 | ) 10 | 11 | os_add_executable(kernel_rng "R.N.Geesus test" ${SOURCES}) 12 | os_add_stdout(kernel_rng default_stdout) 13 | #os_add_drivers(service boot_logger) 14 | os_add_plugins(kernel_rng vfs) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/stl/stl/README.md: -------------------------------------------------------------------------------- 1 | # Test basics of C++ Standard Template Library 2 | This just tests a fraction of STL functionality, but it's here to just verify that basic STL support is in place and working. Useful i.e. when working on porting STL or switching implementation (e.g. to EASTL) 3 | 4 | Sucess: Outputs SUCCESS if all tests pass 5 | Fail: Panic if any test fails 6 | 7 | NOTE: This test uses the `lest` unit test framework as well for some tests. The result of those tests will also be reported. 8 | -------------------------------------------------------------------------------- /test/userspace/microlb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | 3 | project (service C CXX) 4 | 5 | option(PORTABLE "" OFF) 6 | option(ENABLE_S2N "" ON) 7 | 8 | # Human-readable name of your service 9 | set(SERVICE_NAME "Linux userspace microLB test") 10 | # Name of your service binary 11 | set(BINARY "linux_microlb") 12 | 13 | set(INCLUDES 14 | ) 15 | 16 | set(SOURCES 17 | service.cpp 18 | ) 19 | 20 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 21 | -------------------------------------------------------------------------------- /src/musl/mremap.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static long sys_mremap(void */*old_address*/, size_t /*old_size*/, 4 | size_t /*new_size*/, int /*flags*/, void */*new_address*/) 5 | { 6 | return -ENOSYS; 7 | } 8 | 9 | extern "C" 10 | long syscall_SYS_mremap(void *old_address, size_t old_size, 11 | size_t new_size, int flags, void *new_address) 12 | { 13 | return strace(sys_mremap, "mremap", old_address, old_size, new_size, flags, new_address); 14 | } 15 | -------------------------------------------------------------------------------- /test/integration/kernel/stacktrace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | set(ELF_SYMBOLS true) 5 | 6 | project (service) 7 | include(os) 8 | 9 | set(SOURCES 10 | service.cpp 11 | ) 12 | 13 | os_add_executable(kernel_stacktrace "Stacktrace test" ${SOURCES}) 14 | os_add_stdout(kernel_stacktrace default_stdout) 15 | os_add_drivers(kernel_stacktrace boot_logger) 16 | 17 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /test/integration/net/gateway/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_gateway "Gateway test" ${SOURCES}) 12 | 13 | os_add_nacl(net_gateway nacl.txt) 14 | os_add_drivers(net_gateway virtionet e1000 vmxnet3) 15 | os_add_stdout(net_gateway default_stdout) 16 | 17 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /test/integration/net/router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_router "Routing test" ${SOURCES}) 12 | 13 | os_add_drivers(net_router virtionet) 14 | os_add_stdout(net_router default_stdout) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | configure_file(setup.sh ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /src/musl/getdents.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_getdents(unsigned int fd, struct dirent *dirp, unsigned int count) 6 | { 7 | if(auto* fildes = FD_map::_get(fd); fildes) 8 | return fildes->getdents(dirp, count); 9 | 10 | return -EBADF; 11 | } 12 | 13 | extern "C" 14 | long syscall_SYS_getdents(unsigned int fd, struct dirent *dirp, unsigned int count) { 15 | return strace(sys_getdents, "getdents", fd, dirp, count); 16 | } 17 | -------------------------------------------------------------------------------- /test/integration/fs/fat16/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | os_add_executable(fs_fat16 "FAT16 filesystem test" fat16.cpp) 8 | os_add_stdout(fs_fat16 default_stdout) 9 | 10 | os_diskbuilder(fs_fat16 disk) 11 | 12 | configure_file(banana.ascii ${CMAKE_CURRENT_BINARY_DIR}) 13 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 14 | configure_file(vm.json ${CMAKE_CURRENT_BINARY_DIR}) 15 | -------------------------------------------------------------------------------- /test/integration/net/configure/vm.json: -------------------------------------------------------------------------------- 1 | { 2 | "net" : [ 3 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:2a"}, 4 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:3a"}, 5 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:4a"}, 6 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:5a"}, 7 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:6a"}, 8 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:7a"}, 9 | {"device" : "virtio", "mac" : "c0:01:0a:00:00:8a"} 10 | ], 11 | "mem" : 256 12 | } 13 | -------------------------------------------------------------------------------- /userspace/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCES 3 | arch.cpp 4 | config.cpp 5 | main.cpp 6 | os.cpp 7 | profile.cpp 8 | drivers/memdisk.cpp 9 | ) 10 | 11 | if (NOT PORTABLE) 12 | set(SOURCES ${SOURCES} drivers/tap_driver.cpp linux_evloop.cpp) 13 | endif() 14 | 15 | add_library(linuxrt STATIC ${SOURCES}) 16 | install(TARGETS linuxrt DESTINATION $ENV{INCLUDEOS_PREFIX}/includeos/linux) 17 | install(FILES drivers/usernet.hpp DESTINATION $ENV{INCLUDEOS_PREFIX}/includeos/linux/drivers) 18 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp plugin1.cpp plugin2.cpp plugin3.cpp 9 | ) 10 | 11 | os_add_executable(kernel_plugin_init "Plugin init test" ${SOURCES}) 12 | os_add_stdout(kernel_plugin_init default_stdout) 13 | os_add_plugins(kernel_plugin_init example) 14 | 15 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 16 | -------------------------------------------------------------------------------- /test/integration/kernel/smp/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | boot_count = 0 10 | success = False 11 | 12 | def booted(line): 13 | global boot_count 14 | boot_count += 1; 15 | if boot_count > 1: 16 | vm.exit(1, "VM rebooted unexpectedly") 17 | 18 | vm = vmrunner.vms[0] 19 | 20 | vm.on_output("#include // Literally", booted); 21 | 22 | vm.boot(20,image_name='kernel_smp.elf.bin') 23 | -------------------------------------------------------------------------------- /src/musl/fstat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | #include 5 | 6 | static long sys_fstat(int fd, struct stat* stat_buf) 7 | { 8 | if (UNLIKELY(stat_buf == nullptr)) 9 | return -EINVAL; 10 | 11 | if(auto* fildes = FD_map::_get(fd); fildes) 12 | return fildes->fstat(stat_buf); 13 | 14 | return -EBADF; 15 | } 16 | 17 | extern "C" 18 | long syscall_SYS_fstat(int fd, struct stat* stat_buf) { 19 | return strace(sys_fstat, "fstat", fd, stat_buf); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/integration/memory/paging/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp # ...add more here 9 | ) 10 | 11 | os_add_executable(kernel_paging "Page protection test" ${SOURCES}) 12 | os_add_stdout(kernel_paging default_stdout) 13 | os_add_drivers(kernel_paging boot_logger) 14 | os_add_plugins(kernel_paging vfs) 15 | 16 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/posix/tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(posix_tcp "POSIX TCP test" ${SOURCES}) 14 | 15 | os_add_drivers(posix_tcp virtionet) 16 | os_add_stdout(posix_tcp default_stdout) 17 | 18 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 19 | -------------------------------------------------------------------------------- /test/integration/posix/udp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(posix_udp "POSIX UDP test" ${SOURCES}) 14 | 15 | os_add_drivers(posix_udp virtionet) 16 | os_add_stdout(posix_udp default_stdout) 17 | 18 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 19 | -------------------------------------------------------------------------------- /test/unit/fs/unit_fs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace fs; 6 | 7 | CASE("Initialize mock FS") 8 | { 9 | fs::MemDisk memdisk {0, 0}; 10 | fs::Disk disk { memdisk }; 11 | 12 | EXPECT(disk.empty()); 13 | EXPECT(disk.device_id() >= 0); 14 | EXPECT(disk.name().size() > 1); // name0 15 | disk.init_fs( 16 | [&] (fs::error_t error, fs::File_system& fs) 17 | { 18 | EXPECT(error != fs::no_error); 19 | }); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/musl/pipe.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static long sys_pipe([[maybe_unused]]int pipefd[2]) 4 | { 5 | return -ENOSYS; 6 | } 7 | 8 | static long sys_pipe2([[maybe_unused]]int pipefd[2], [[maybe_unused]]int flags) 9 | { 10 | return -ENOSYS; 11 | } 12 | 13 | extern "C" { 14 | long syscall_SYS_pipe(int pipefd[2]) { 15 | return strace(sys_pipe, "pipe", pipefd); 16 | } 17 | 18 | long syscall_SYS_pipe2(int pipefd[2], int flags) { 19 | return strace(sys_pipe2, "pipe2", pipefd, flags); 20 | } 21 | } // extern "C" 22 | -------------------------------------------------------------------------------- /test/integration/kernel/memmap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(kernel_memmap "Memmap test" ${SOURCES}) 12 | os_add_stdout(kernel_memmap default_stdout) 13 | 14 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 15 | configure_file(vm1.json ${CMAKE_CURRENT_BINARY_DIR}) 16 | configure_file(vm2.json ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /test/integration/net/dhcpd_dhclient_linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | os_add_executable(net_dhcpd_dhclient_linux "IncludeOS DHCP server test" service.cpp) 8 | 9 | os_add_plugins(net_dhcpd_dhclient_linux autoconf) 10 | os_add_drivers(net_dhcpd_dhclient_linux virtionet) 11 | os_add_stdout(net_dhcpd_dhclient_linux default_stdout) 12 | 13 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 14 | -------------------------------------------------------------------------------- /test/integration/kernel/osinit/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from vmrunner import vmrunner 4 | vm = vmrunner.vms[0] 5 | 6 | 7 | def done(line): 8 | if "Healthy" in line: 9 | vm.exit(0, "OS initialization test succeeded") 10 | elif "failed" in line: 11 | status = line.split(":")[1].strip() 12 | vm.exit(1, status) 13 | else: 14 | vm.exit(2, "OS initialization test failed") 15 | 16 | vm.on_output("Diagnose complete", done) 17 | 18 | 19 | vm.boot(20, image_name='osinit.elf.bin') 20 | -------------------------------------------------------------------------------- /test/integration/hw/vga/Makefile: -------------------------------------------------------------------------------- 1 | ################################################# 2 | # IncludeOS SERVICE makefile # 3 | ################################################# 4 | 5 | # The name of your service 6 | SERVICE = test_vga 7 | SERVICE_NAME = The VGA Test Service 8 | 9 | # Your service parts 10 | FILES=vga.cpp 11 | # Your disk image 12 | DISK= 13 | 14 | # IncludeOS location 15 | ifndef INCLUDEOS_INSTALL 16 | INCLUDEOS_INSTALL=$(HOME)/IncludeOS_install 17 | endif 18 | 19 | include $(INCLUDEOS_INSTALL)/Makeseed 20 | -------------------------------------------------------------------------------- /test/integration/posix/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | option(NORMAL "" ON) 8 | if (NORMAL) 9 | set(SOURCES service.cpp) 10 | else() 11 | set(SOURCES main_no_params.cpp) 12 | endif() 13 | 14 | os_add_executable(posix_main "POSIX main test" ${SOURCES}) 15 | 16 | os_add_plugins(posix_main vfs) 17 | os_add_stdout(posix_main default_stdout) 18 | 19 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 20 | -------------------------------------------------------------------------------- /test/integration/fs/ide_write/fat32_disk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### FAT32 TEST DISK ### 4 | 5 | DISK=my.disk 6 | MOUNTDIR=tmpdisk 7 | 8 | # If no arg supplied, setup disk 9 | if [ $# -eq 0 ] 10 | then 11 | 12 | # Remove disk if exists 13 | rm -f $DISK 14 | # Preallocate space to file 15 | truncate -s 1M $DISK 16 | # Create FAT32 filesystem on "my.disk" 17 | mkfs.fat $DISK 18 | 19 | # If "clean" is supplied, clean up 20 | elif [ $1 = "clean" ] 21 | then 22 | echo "> Cleaning up TEST DISK: $DISK" 23 | rm -f $DISK 24 | fi 25 | -------------------------------------------------------------------------------- /test/integration/posix/syslog_plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(posix_syslog_plugin "POSIX syslog plugin test" ${SOURCES}) 12 | 13 | os_add_drivers(posix_syslog_plugin virtionet) 14 | os_add_plugins(posix_syslog_plugin syslog syslogd) 15 | os_add_stdout(posix_syslog_plugin default_stdout) 16 | 17 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 18 | -------------------------------------------------------------------------------- /api/kernel/diag.hpp: -------------------------------------------------------------------------------- 1 | #ifndef KERNEL_DIAG_HOOKS_HPP 2 | #define KERNEL_DIAG_HOOKS_HPP 3 | #define RUN_DIAG_HOOKS true 4 | 5 | constexpr bool run_diag_hooks = RUN_DIAG_HOOKS; 6 | 7 | namespace kernel::diag { 8 | void post_bss() noexcept; 9 | void post_machine_init() noexcept; 10 | void post_init_libc() noexcept; 11 | void post_service() noexcept; 12 | 13 | void default_post_init_libc() noexcept; 14 | 15 | template 16 | void hook() { 17 | if constexpr (run_diag_hooks) { 18 | Func(); 19 | } 20 | } 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/platform/aarch64_vm/stop.asm: -------------------------------------------------------------------------------- 1 | .global vm_exit 2 | vm_exit: 3 | /* 0x20026 == ADP_Stopped_ApplicationExit */ 4 | mov x1, #0x26 5 | movk x1, #2, lsl #16 6 | str x1, [sp,#0] 7 | 8 | /* Exit status code. Host QEMU process exits with that status. */ 9 | mov x0, #0 10 | str x0, [sp,#8] 11 | 12 | /* x1 contains the address of parameter block. 13 | * Any memory address could be used. */ 14 | mov x1, sp 15 | 16 | /* SYS_EXIT */ 17 | mov w0, #0x18 18 | 19 | /* Do the semihosting call on A64. */ 20 | hlt 0xf000 21 | -------------------------------------------------------------------------------- /test/userspace/tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | # Human-readable name of your service 8 | set(SERVICE_NAME "Linux userspace TCP test") 9 | 10 | # Name of your service binary 11 | set(BINARY "linux_tcp") 12 | 13 | # Source files to be linked with OS library parts to form bootable image 14 | set(SOURCES 15 | service.cpp 16 | ) 17 | 18 | include($ENV{INCLUDEOS_PREFIX}/cmake/linux.service.cmake) 19 | -------------------------------------------------------------------------------- /src/arch/i686/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf32") 2 | 3 | ### i686 arch specific ### 4 | set(ARCH_OBJECTS 5 | gdt_asm.asm 6 | profile_intr.asm 7 | apic_asm.asm 8 | arch_start.asm 9 | arch_musl.cpp 10 | exceptions.asm 11 | interrupts.asm 12 | fiber.asm 13 | paging.cpp 14 | ) 15 | 16 | add_library(arch STATIC ${ARCH_OBJECTS}) 17 | 18 | set_target_properties(arch PROPERTIES LINKER_LANGUAGE CXX) 19 | install(TARGETS arch DESTINATION lib) 20 | install(FILES linker.ld DESTINATION .) 21 | configure_file(linker.ld ${CMAKE_BINARY_DIR}) 22 | -------------------------------------------------------------------------------- /test/integration/net/vlan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_config(net_vlan "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(net_vlan "VLAN test" ${SOURCES}) 14 | 15 | os_add_plugins(net_vlan autoconf) 16 | os_add_drivers(net_vlan virtionet e1000 vmxnet3) 17 | os_add_stdout(net_vlan default_stdout) 18 | 19 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 20 | -------------------------------------------------------------------------------- /test/integration/plugin/unik/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(plugin_unik "UNIK plugin test" ${SOURCES}) 14 | 15 | os_add_drivers(plugin_unik virtionet) 16 | os_add_plugins(plugin_unik unik) 17 | os_add_stdout(plugin_unik default_stdout) 18 | 19 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 20 | -------------------------------------------------------------------------------- /src/musl/gettimeofday.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_gettimeofday(struct timeval *tv, struct timezone *tz) 5 | { 6 | timespec t = __arch_wall_clock(); 7 | tv->tv_sec = t.tv_sec; 8 | tv->tv_usec = t.tv_nsec * 1000; 9 | if (tz != nullptr) { 10 | tz->tz_minuteswest = 0; 11 | tz->tz_dsttime = 0; /* DST_NONE */ 12 | } 13 | return 0; 14 | } 15 | 16 | extern "C" 17 | long syscall_SYS_gettimeofday(struct timeval *tv, struct timezone *tz) { 18 | return strace(sys_gettimeofday, "gettimeofday", tv, tz); 19 | } 20 | -------------------------------------------------------------------------------- /test/integration/fs/virtio_block/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import subprocess 5 | import os 6 | 7 | thread_timeout = 50 8 | 9 | subprocess.call(['./image.sh'], timeout=thread_timeout) 10 | 11 | def cleanup(): 12 | subprocess.call(['./cleanup.sh']) 13 | 14 | from vmrunner import vmrunner 15 | vm = vmrunner.vms[0] 16 | 17 | vm.on_exit(cleanup) 18 | 19 | if len(sys.argv) > 1: 20 | vm.boot(thread_timeout,image_name=str(sys.argv[1])) 21 | else: 22 | vm.boot(thread_timeout,image_name='fs_virtio_block.elf.bin') 23 | -------------------------------------------------------------------------------- /src/musl/mlock.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_mlock(const void* /* addr */, size_t /* len */) 5 | { 6 | return -ENOSYS; 7 | } 8 | static long sys_munlock(const void* /* addr */, size_t /* len */) 9 | { 10 | return -ENOSYS; 11 | } 12 | 13 | extern "C" 14 | long syscall_SYS_mlock(const void* addr, size_t len) 15 | { 16 | return strace(sys_mlock, "mlock", addr, len); 17 | } 18 | extern "C" 19 | long syscall_SYS_munlock(const void *addr, size_t len) 20 | { 21 | return strace(sys_munlock, "munlock", addr, len); 22 | } 23 | -------------------------------------------------------------------------------- /test/integration/net/icmp6/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service C CXX) 5 | 6 | # Human-readable name of your service 7 | set(SERVICE_NAME "Linux userspace ICMP6 test") 8 | 9 | # Name of your service binary 10 | set(BINARY "icmp6") 11 | 12 | # Source files to be linked with OS library parts to form bootable image 13 | set(SOURCES 14 | ../service.cpp 15 | ) 16 | 17 | set(EXTRA_LIBS 18 | ) 19 | 20 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 21 | -------------------------------------------------------------------------------- /test/integration/net/tcp/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service C CXX) 5 | 6 | # Human-readable name of your service 7 | set(SERVICE_NAME "Linux userspace TCP test") 8 | 9 | # Name of your service binary 10 | set(BINARY "tcp_test") 11 | 12 | # Source files to be linked with OS library parts to form bootable image 13 | set(SOURCES 14 | ../service.cpp 15 | ) 16 | 17 | set(EXTRA_LIBS 18 | ) 19 | 20 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 21 | -------------------------------------------------------------------------------- /test/misc/test_solo5_spt.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e # Exit immediately on error (we're trapping the exit signal) 3 | trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG 4 | trap 'echo -e "\nINSTALL FAILED ON COMMAND: $previous_command\n"' EXIT 5 | 6 | export SYSTEM=`uname -s` 7 | 8 | if [[ ! $SYSTEM =~ .*[L|l]inux.* ]] 9 | then 10 | echo -e "\nRunning Solo5 is currently only supported on Linux. \n" 11 | trap - EXIT 12 | exit 1 13 | fi 14 | 15 | pushd examples/demo_service 16 | mkdir -p build 17 | boot --with-solo5-spt . 18 | popd 19 | trap - EXIT 20 | -------------------------------------------------------------------------------- /test/integration/hw/serial/Makefile: -------------------------------------------------------------------------------- 1 | ################################################# 2 | # IncludeOS SERVICE makefile # 3 | ################################################# 4 | 5 | # The name of your service 6 | SERVICE = test_serial 7 | SERVICE_NAME = Serial port Test Service 8 | 9 | # Your service parts 10 | FILES = service.cpp 11 | 12 | # Your disk image 13 | DISK= 14 | LOCAL_INCLUDES= 15 | 16 | # IncludeOS location 17 | ifndef INCLUDEOS_INSTALL 18 | INCLUDEOS_INSTALL=$(HOME)/IncludeOS_install 19 | endif 20 | 21 | include $(INCLUDEOS_INSTALL)/Makeseed 22 | -------------------------------------------------------------------------------- /test/misc/test_solo5_hvt.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | set -e # Exit immediately on error (we're trapping the exit signal) 3 | trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG 4 | trap 'echo -e "\nINSTALL FAILED ON COMMAND: $previous_command\n"' EXIT 5 | 6 | 7 | export SYSTEM=`uname -s` 8 | 9 | if [[ ! $SYSTEM =~ .*[L|l]inux.* ]] 10 | then 11 | echo -e "\nRunning Solo5 is currently only supported on Linux. \n" 12 | trap - EXIT 13 | exit 1 14 | fi 15 | 16 | pushd examples/demo_service 17 | mkdir -p build 18 | boot --with-solo5-hvt . 19 | popd 20 | trap - EXIT 21 | -------------------------------------------------------------------------------- /src/musl/rt_sigaction.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | static int sys_sigaction(int signum, 4 | const struct sigaction* act, 5 | const struct sigaction* oldact) 6 | { 7 | (void) signum; 8 | (void) act; 9 | (void) oldact; 10 | return -ENOSYS; 11 | } 12 | 13 | extern "C" 14 | int syscall_SYS_rt_sigaction(int signum, 15 | const struct sigaction* act, 16 | const struct sigaction* oldact) 17 | { 18 | return strace(sys_sigaction, "rt_sigaction", signum, act, oldact); 19 | } 20 | -------------------------------------------------------------------------------- /api/fuzz/macfuzzy.hpp: -------------------------------------------------------------------------------- 1 | // __ __ ___ _ _ 2 | // | \/ | __ _ __ | __| _ _ ___ ___ | || | 3 | // | |\/| | / _` | / _| | _| | +| | |_ / |_ / \_, | 4 | // |_|__|_| \__,_| \__|_ _|_|_ \_,_| _/__| _/__| _|__/ 5 | // _|"""""|_|"""""|_|"""""|_| """ |_|"""""|_|"""""|_|"""""|_| """"| 6 | // "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' 7 | #pragma once 8 | #include "fuzzy_helpers.hpp" 9 | #include "fuzzy_stack.hpp" 10 | #include "fuzzy_packet.hpp" 11 | //#include "fuzzy_stream.hpp" 12 | -------------------------------------------------------------------------------- /src/musl/prlimit64.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_prlimit64(pid_t /*pid*/, int /*resource*/, 5 | const struct rlimit */*new_limit*/, 6 | struct rlimit */*old_limit*/) 7 | { 8 | return -ENOSYS; 9 | } 10 | 11 | extern "C" 12 | long syscall_SYS_prlimit64(pid_t pid, int resource, 13 | const struct rlimit *new_limit, 14 | struct rlimit *old_limit) 15 | { 16 | return strace(sys_prlimit64, "prlimit64", pid, resource, new_limit, old_limit); 17 | } 18 | -------------------------------------------------------------------------------- /test/integration/net/configure/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_config(net_configure "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(net_configure "Configure test" ${SOURCES}) 14 | 15 | os_add_plugins(net_configure autoconf) 16 | os_add_drivers(net_configure virtionet boot_logger) 17 | os_add_stdout(net_configure default_stdout) 18 | 19 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 20 | -------------------------------------------------------------------------------- /test/userspace/router/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | # Human-readable name of your service 8 | set(SERVICE_NAME "Linux userspace router test") 9 | 10 | # Name of your service binary 11 | set(BINARY "linux_router") 12 | 13 | # Source files to be linked with OS library parts to form bootable image 14 | set(SOURCES 15 | ../service.cpp 16 | nacl.cpp 17 | ) 18 | 19 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 20 | -------------------------------------------------------------------------------- /src/musl/uname.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_uname(struct utsname *buf) { 6 | if(UNLIKELY(buf == nullptr)) 7 | return -EFAULT; 8 | 9 | strcpy(buf->sysname, "IncludeOS"); 10 | 11 | strcpy(buf->nodename, "IncludeOS-node"); 12 | 13 | strcpy(buf->release, os::version()); 14 | 15 | strcpy(buf->version, os::version()); 16 | 17 | strcpy(buf->machine, os::arch()); 18 | 19 | return 0; 20 | } 21 | 22 | extern "C" 23 | long syscall_SYS_uname(struct utsname *buf) { 24 | return strace(sys_uname, "uname", buf); 25 | } 26 | -------------------------------------------------------------------------------- /test/integration/fs/fat16/README.md: -------------------------------------------------------------------------------- 1 | # FAT16 Test Service 2 | 3 | Test the functionalty of the FAT16 filesystem with the use of memdisk. 4 | 5 | The test verifies the following things: 6 | 7 | 1. The disk size. 8 | 2. Auto mounting/recognition of filesystem. 9 | 3. Disk structure. 10 | 4. Disk content with the help of `banana.txt` and `banana.ascii`. 11 | 5. Filesystem API (read) and subclasses as `Dirent`. 12 | 6. Random access sync read. 13 | 14 | `fat16_disk.sh` is used to create a 8 MB FAT16 disk `my.disk` with `banana.txt` as content, which will be included as a memdisk into the service. 15 | 16 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/plugin3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern int my_plugin_functions; 5 | int f3_data = 0; 6 | 7 | // The OS will no longer catch exceptions in plugins 8 | class myexcept : public std::exception { 9 | using std::exception::exception; 10 | const char* what() const noexcept override{ 11 | f3_data = 0xf417; 12 | return "My plugin message"; 13 | } 14 | }; 15 | 16 | __attribute__((constructor)) 17 | static void func3(){ 18 | INFO("Plugin 3","initialization function 3"); 19 | my_plugin_functions++; 20 | f3_data = 0xf3; 21 | } 22 | -------------------------------------------------------------------------------- /test/integration/net/udp/README.md: -------------------------------------------------------------------------------- 1 | # Test UDP functionality 2 | 3 | This service sets up a UDP "parrot" i.e. a UDP server that listens to a certain port, and echos back to you anything you send to it. 4 | 5 | ### TODO 6 | 7 | 1. Make an external test script (or a test program using e.g. google test) that writes random byte sequences in, and verifies that the output is identical. 8 | 2. Find out what happens when there is more data than one frame can hold (i.e. 1500 bytes minus headers) - and compare with what sould happen, i.e. what happens with a normal C-socket in Linux. 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/integration/posix/syslog_default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(posix_syslog_default "POSIX syslog test" ${SOURCES}) 14 | 15 | #os_add_drivers(service boot_logger) 16 | os_add_plugins(posix_syslog_default syslog) 17 | os_add_stdout(posix_syslog_default default_stdout) 18 | 19 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 20 | -------------------------------------------------------------------------------- /test/integration/kernel/LiveUpdate/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | import socket 6 | 7 | from vmrunner import vmrunner 8 | vm = vmrunner.vms[0] 9 | 10 | 11 | def begin_test(line): 12 | f = open('./kernel_LiveUpdate','rb') 13 | 14 | s = socket.socket() 15 | s.connect(("10.0.0.59", 666)) 16 | s.send(f.read()) 17 | s.close() 18 | 19 | vm.on_output("Ready to receive binary blob", begin_test) 20 | if len(sys.argv) > 1: 21 | vm.boot(40,image_name=str(sys.argv[1])) 22 | else: 23 | vm.boot(40,image_name='kernel_LiveUpdate.elf.bin') 24 | -------------------------------------------------------------------------------- /test/integration/net/icmp6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | ) 10 | 11 | os_add_executable(net_icmp6 "ICMPv6 test" ${SOURCES}) 12 | os_add_stdout(net_icmp6 default_stdout) 13 | 14 | # DRIVERS / PLUGINS: 15 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 16 | os_add_drivers(net_icmp6 17 | solo5net 18 | ) 19 | else() 20 | os_add_drivers(net_icmp6 21 | virtionet 22 | ) 23 | endif() 24 | 25 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 26 | -------------------------------------------------------------------------------- /src/platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${PLATFORM} STREQUAL "solo5-hvt") 2 | message(STATUS "platform x86_solo5") 3 | add_subdirectory(x86_solo5) 4 | elseif(${PLATFORM} STREQUAL "solo5-spt") 5 | message(FATAL_ERROR "SPT not implemented yet") 6 | elseif (${PLATFORM} STREQUAL "nano") 7 | if (${ARCH} STREQUAL "aarch64") 8 | add_subdirectory(aarch64_vm) 9 | else() 10 | add_subdirectory(x86_nano) 11 | endif() 12 | else() 13 | if (${ARCH} STREQUAL "aarch64") 14 | add_subdirectory(aarch64_vm) 15 | else() 16 | message(STATUS "platform x86_pc") 17 | add_subdirectory(x86_pc) 18 | endif() 19 | endif() 20 | -------------------------------------------------------------------------------- /src/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCS 2 | async.cpp 3 | statman.cpp 4 | logger.cpp 5 | sha1.cpp 6 | syslog_facility.cpp 7 | syslogd.cpp 8 | percent_encoding.cpp 9 | path_to_regex.cpp 10 | crc32.cpp 11 | ) 12 | 13 | #if (NOT CMAKE_TESTING_ENABLED) 14 | 15 | if (NOT ${PLATFORM} STREQUAL "nano") 16 | include_directories(${CMAKE_SOURCE_DIR}/lib/LiveUpdate/include) 17 | list(APPEND SRCS 18 | memstream.c 19 | tar.cpp 20 | uri.cpp #rapidjson 21 | autoconf.cpp 22 | config.cpp 23 | statman_liu.cpp 24 | ) 25 | endif() 26 | 27 | 28 | 29 | add_library(util OBJECT ${SRCS}) 30 | -------------------------------------------------------------------------------- /test/integration/posix/file_fd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | test_file_fd.cpp 9 | ) 10 | 11 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 12 | 13 | os_add_executable(posix_file_fd "POSIX file descriptor test" ${SOURCES}) 14 | 15 | os_add_plugins(posix_file_fd vfs) 16 | os_add_stdout(posix_file_fd default_stdout) 17 | 18 | # Create memdisk from folder 19 | os_diskbuilder(posix_file_fd disk) 20 | 21 | configure_file (test.py ${CMAKE_CURRENT_BINARY_DIR}) 22 | -------------------------------------------------------------------------------- /test/integration/posix/stat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | set(SOURCES 8 | test_stat_ftw.cpp 9 | ftw_tests.cpp 10 | stat_tests.cpp 11 | ) 12 | 13 | os_add_executable(posix_stat "POSIX file descriptor test" ${SOURCES}) 14 | 15 | os_add_drivers(posix_stat boot_logger) 16 | os_add_plugins(posix_stat vfs) 17 | os_add_stdout(posix_stat default_stdout) 18 | 19 | # Create memdisk from folder 20 | os_diskbuilder(posix_stat disk) 21 | 22 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 23 | -------------------------------------------------------------------------------- /test/integration/fs/memdisk/README.md: -------------------------------------------------------------------------------- 1 | # MemDisk Test Service 2 | 3 | Test to see that MemDisk is working correctly - also verifying the disk interface. 4 | 5 | This test composed of 3 separate services: 6 | 7 | 1. Test a memdisk with 0 sectors (`sector0.disk`) 8 | - Verifies that the disk is empty. 9 | 2. Test a memdisk with 2 sectors (`sector2.disk`) 10 | - Verifies that the disk is 2 sectors. 11 | - Verifies reading and comparing binary data. 12 | 3. Test a big memdisk of 256 000 sectors (created by `bigdisk.sh`) 13 | - Verifies that a big disk is correctly included. 14 | - Verifies MBR (Master Boot Record) signature. 15 | -------------------------------------------------------------------------------- /test/integration/kernel/fiber/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | if (DEFINED ENV{INCLUDEOS_THREADING}) 4 | option(threading "" ENV{INCLUDEOS_THREADING}) 5 | endif() 6 | 7 | project (service) 8 | include(os) 9 | 10 | set(SOURCES 11 | service.cpp 12 | ) 13 | if (threading) 14 | list(APPEND SOURCES fiber_smp.cpp) 15 | endif() 16 | 17 | os_add_executable(kernel_fiber "GRUB boot test" ${SOURCES}) 18 | os_add_stdout(kernel_fiber default_stdout) 19 | os_add_drivers(kernel_fiber boot_logger) 20 | 21 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 22 | -------------------------------------------------------------------------------- /src/musl/select.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | long sys_select(int /*nfds*/, 5 | fd_set* /*readfds*/, 6 | fd_set* /*writefds*/, 7 | fd_set* /*exceptfds*/, 8 | struct timeval* /*timeout*/) 9 | { 10 | return -ENOSYS; 11 | } 12 | 13 | extern "C" 14 | long syscall_SYS_select(int nfds, 15 | fd_set* readfds, 16 | fd_set* writefds, 17 | fd_set* exceptfds, 18 | struct timeval* timeout) 19 | { 20 | return strace(sys_select, "select", nfds, readfds, writefds, exceptfds, timeout); 21 | } 22 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/create_disk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e #stop on first error 3 | ### DISK CREATION ### 4 | MOUNTDIR=tmpdisk 5 | 6 | # Set local directory to first param if provided, default to memdisk 7 | CONTENT=$1 8 | LOCALDIR=$2 9 | LOCALDIR=${LOCALDIR:-memdisk} 10 | 11 | DISK=$LOCALDIR.disk 12 | 13 | rm -f $DISK 14 | echo ">> Creating disk image from $LOCALDIR to $LOCALDIR.disk" 15 | truncate -s 1048576 $DISK # 256000 sectors 16 | sudo mkfs.fat $DISK 17 | mkdir -p $MOUNTDIR 18 | sudo mount $DISK $MOUNTDIR 19 | sudo cp -r $CONTENT/* $MOUNTDIR 20 | sudo sync # Mui Importante 21 | sudo umount $MOUNTDIR 22 | rm -rf $MOUNTDIR 23 | -------------------------------------------------------------------------------- /src/arch/x86_64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) 2 | 3 | ### x86_64 arch specific ### 4 | set(ARCH_OBJECTS 5 | apic_asm.asm 6 | apic_longmode.asm 7 | arch_start.asm 8 | arch_musl.cpp 9 | exceptions.asm 10 | interrupts.asm 11 | fiber_asm.asm 12 | __syscall_entry.asm 13 | syscall_entry.cpp 14 | ist.cpp 15 | paging.cpp 16 | init_paging.cpp 17 | ) 18 | 19 | add_library(arch STATIC ${ARCH_OBJECTS}) 20 | set_target_properties(arch PROPERTIES LINKER_LANGUAGE CXX) 21 | configure_file(linker.ld ${CMAKE_BINARY_DIR}) 22 | install(TARGETS arch DESTINATION lib) 23 | install(FILES linker.ld DESTINATION .) 24 | -------------------------------------------------------------------------------- /test/userspace/microlb/client.py: -------------------------------------------------------------------------------- 1 | import requests 2 | expected_string = "#" * 1024 * 50 3 | 4 | def validateRequest(addr): 5 | #response = requests.get('https://10.0.0.42:443', verify=False, timeout=5) 6 | response = requests.get('http://10.0.0.42', timeout=5) 7 | return (response.content) == str(addr) + expected_string 8 | 9 | print "Starting test..." 10 | assert validateRequest(6001) 11 | assert validateRequest(6002) 12 | assert validateRequest(6003) 13 | assert validateRequest(6004) 14 | 15 | assert validateRequest(6001) 16 | assert validateRequest(6002) 17 | assert validateRequest(6003) 18 | assert validateRequest(6004) 19 | -------------------------------------------------------------------------------- /test/userspace/s2n/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | 3 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 4 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 5 | endif() 6 | project (service C CXX) 7 | 8 | # Human-readable name of your service 9 | set(SERVICE_NAME "Linux userspace S2N test") 10 | # Name of your service binary 11 | set(BINARY "linux_s2n") 12 | 13 | set(INCLUDES 14 | ) 15 | 16 | set(SOURCES 17 | service.cpp 18 | serial.cpp 19 | ) 20 | 21 | option(ENABLE_S2N "" ON) 22 | option(STATIC_BUILD "" OFF) 23 | option(STRIP_BINARY "" OFF) 24 | 25 | include($ENV{INCLUDEOS_PREFIX}/cmake/linux.service.cmake) 26 | -------------------------------------------------------------------------------- /src/musl/write.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "common.hpp" 3 | #include 4 | 5 | // The actual syscall 6 | static long sys_write(int fd, char* str, size_t len) { 7 | 8 | if (fd == 1 or fd == 2) 9 | { 10 | os::print(str, len); 11 | return len; 12 | } 13 | 14 | if(auto* fildes = FD_map::_get(fd); fildes) 15 | return fildes->write(str, len); 16 | 17 | return -EBADF; 18 | } 19 | 20 | // The syscall wrapper, using strace if enabled 21 | extern "C" 22 | long syscall_SYS_write(int fd, char* str, size_t len) { 23 | //return strace(sys_write, "write", fd, str, len); 24 | return sys_write(fd, str, len); 25 | } 26 | -------------------------------------------------------------------------------- /test/integration/posix/syslog_plugin/README.md: -------------------------------------------------------------------------------- 1 | # Syslog Integration Test UDP 2 | 3 | Testing POSIX syslog and IncludeOS syslogd implementation. 4 | 5 | This tests the plugin behavior a.k.a. sending syslog data over UDP port 6514. 6 | 7 | The message format corresponds to the format specified in RFC5424. 8 | 9 | To achieve this behavior you have to add `set(PLUGINS syslogd)` to your CMakeLists.txt file. 10 | 11 | The default behavior for IncludeOS's syslog implementation is however to send the data to printf, which is 12 | what you get if you don't add `set(PLUGINS syslogd)` to your CMakeLists.txt file (see the syslog_default integration test). 13 | -------------------------------------------------------------------------------- /test/integration/posix/conf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project (service) 5 | include(os) 6 | 7 | set(SOURCES 8 | service.cpp 9 | test_sysconf.c 10 | test_pathconf.c 11 | test_pwd.c 12 | ) 13 | 14 | #os_add_config(service "${CMAKE_CURRENT_SOURCE_DIR}/config.json") 15 | 16 | os_add_executable(posix_conf "POSIX pathconf test" ${SOURCES}) 17 | 18 | os_add_plugins(posix_conf vfs) 19 | os_add_stdout(posix_conf default_stdout) 20 | 21 | # Create memdisk from folder 22 | os_diskbuilder(posix_conf disk) 23 | 24 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 25 | -------------------------------------------------------------------------------- /src/platform/x86_nano/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(LIBNAME ${ARCH}_nano) 2 | set(PLATFORM_OBJECTS 3 | ../x86_pc/start.asm 4 | ../x86_pc/serial1.cpp 5 | ../x86_pc/idt.cpp 6 | platform.cpp 7 | kernel_start.cpp 8 | ) 9 | 10 | add_library(${LIBNAME} STATIC ${PLATFORM_OBJECTS}) 11 | set_target_properties(${LIBNAME} PROPERTIES LINKER_LANGUAGE CXX) 12 | set_target_properties(${LIBNAME} 13 | PROPERTIES 14 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/platform 15 | ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/platform 16 | ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/platform 17 | ) 18 | 19 | 20 | install(TARGETS ${LIBNAME} DESTINATION platform) 21 | -------------------------------------------------------------------------------- /test/integration/fs/fat32/banana.txt: -------------------------------------------------------------------------------- 1 | ____ ___ 2 | | _ \ ___ _ _.' _ `. 3 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 4 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 5 | | `.[_) ) _ | \| | (_) | | | | |.',..| 6 | ':. `. /| | | | | _ | |\ | | |.' :;::' 7 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 8 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 9 | ';:' `::;::;' '' ., . 10 | `: .,. `' .::... . .::;::;' 11 | `..:;::;:.. ::;::;:;:;, :;::;' 12 | "-:;::;:;: ':;::;:'' ;.-' 13 | ""`---...________...---'"" 14 | -------------------------------------------------------------------------------- /test/integration/fs/ide/banana.txt: -------------------------------------------------------------------------------- 1 | ____ ___ 2 | | _ \ ___ _ _.' _ `. 3 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 4 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 5 | | `.[_) ) _ | \| | (_) | | | | |.',..| 6 | ':. `. /| | | | | _ | |\ | | |.' :;::' 7 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 8 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 9 | ';:' `::;::;' '' ., . 10 | `: .,. `' .::... . .::;::;' 11 | `..:;::;:.. ::;::;:;:;, :;::;' 12 | "-:;::;:;: ':;::;:'' ;.-' 13 | ""`---...________...---'"" 14 | -------------------------------------------------------------------------------- /test/integration/fs/fat16/disk/banana.txt: -------------------------------------------------------------------------------- 1 | ____ ___ 2 | | _ \ ___ _ _.' _ `. 3 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 4 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 5 | | `.[_) ) _ | \| | (_) | | | | |.',..| 6 | ':. `. /| | | | | _ | |\ | | |.' :;::' 7 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 8 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 9 | ';:' `::;::;' '' ., . 10 | `: .,. `' .::... . .::;::;' 11 | `..:;::;:.. ::;::;:;:;, :;::;' 12 | "-:;::;:;: ':;::;:'' ;.-' 13 | ""`---...________...---'"" 14 | -------------------------------------------------------------------------------- /test/integration/fs/ide/README.md: -------------------------------------------------------------------------------- 1 | # FAT32 Test Service 2 | 3 | Test the functionalty of the FAT32 filesystem with the use of VirioBlk disk. 4 | 5 | The test verifies the following things: 6 | 7 | 1. The disk size. 8 | 2. Auto mounting/recognition of filesystem. 9 | 3. Disk structure. 10 | 4. Disk content with the help of `banana.txt` and `banana.ascii`. 11 | 5. Filesystem API (read) and subclasses as `Dirent`. 12 | 6. Remounting of filesystem. 13 | 7. Asynchronous operations (also nested like stat into read). 14 | 15 | `fat32_disk.sh` is used to create a 4 GB FAT32 disk `my.disk` with `banana.txt` as content, which will be included by qemu as a separate drive. 16 | 17 | -------------------------------------------------------------------------------- /test/integration/fs/ide_write/banana.txt: -------------------------------------------------------------------------------- 1 | ____ ___ 2 | | _ \ ___ _ _.' _ `. 3 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 4 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 5 | | `.[_) ) _ | \| | (_) | | | | |.',..| 6 | ':. `. /| | | | | _ | |\ | | |.' :;::' 7 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 8 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 9 | ';:' `::;::;' '' ., . 10 | `: .,. `' .::... . .::;::;' 11 | `..:;::;:.. ::;::;:;:;, :;::;' 12 | "-:;::;:;: ':;::;:'' ;.-' 13 | ""`---...________...---'"" 14 | -------------------------------------------------------------------------------- /test/integration/kernel/memmap/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | from builtins import str 5 | import sys 6 | import os 7 | 8 | from vmrunner import vmrunner 9 | 10 | image_name="kernel_memmap.elf.bin" 11 | 12 | def test2(): 13 | print("Booting VM 2 - lots of memory") 14 | vm = vmrunner.vm(config = "vm2.json") 15 | vm.boot(20, image_name = image_name) 16 | 17 | vm = vmrunner.vm(config = "vm1.json") 18 | vm.on_exit_success(test2) 19 | print("Booting VM 1 - default amount of memory") 20 | 21 | if len(sys.argv) > 1: 22 | vm.boot(image_name=str(sys.argv[1])) 23 | else: 24 | vm.boot(20,image_name=image_name) 25 | -------------------------------------------------------------------------------- /test/userspace/liveupdate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | option(STRIP_BINARY "" OFF) 8 | option(STATIC_BUILD "" OFF) # avoid compiler bug 9 | 10 | # Human-readable name of your service 11 | set(SERVICE_NAME "Linux userspace LiveUpdate test") 12 | 13 | # Name of your service binary 14 | set(BINARY "linux_liu") 15 | 16 | # Source files to be linked with OS library parts to form bootable image 17 | set(SOURCES 18 | service.cpp 19 | ) 20 | 21 | include($ENV{INCLUDEOS_PREFIX}/cmake/linux.service.cmake) 22 | -------------------------------------------------------------------------------- /src/musl/writev.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | static long sys_writev(int fd, const struct iovec *iov, int iovcnt) 5 | { 6 | if (fd == 1 || fd == 2) 7 | { 8 | long res = 0; 9 | for(int i = 0; i < iovcnt; i++) 10 | { 11 | auto* text = (const char*)iov[i].iov_base; 12 | auto len = iov[i].iov_len; 13 | os::print(text, len); 14 | res += len; 15 | } 16 | return res; 17 | } 18 | return 0; 19 | } 20 | 21 | extern "C" 22 | long syscall_SYS_writev(int fd, const struct iovec *iov, int iovcnt){ 23 | //return strace(sys_writev, "writev", fd, iov, iovcnt); 24 | return sys_writev(fd, iov, iovcnt); 25 | } 26 | -------------------------------------------------------------------------------- /test/integration/fs/fat32/README.md: -------------------------------------------------------------------------------- 1 | # FAT32 Test Service 2 | 3 | Test the functionalty of the FAT32 filesystem with the use of VirioBlk disk. 4 | 5 | The test verifies the following things: 6 | 7 | 1. The disk size. 8 | 2. Auto mounting/recognition of filesystem. 9 | 3. Disk structure. 10 | 4. Disk content with the help of `banana.txt` and `banana.ascii`. 11 | 5. Filesystem API (read) and subclasses as `Dirent`. 12 | 6. Remounting of filesystem. 13 | 7. Asynchronous operations (also nested like stat into read). 14 | 15 | `fat32_disk.sh` is used to create a 4 GB FAT32 disk `my.disk` with `banana.txt` as content, which will be included by qemu as a separate drive. 16 | 17 | -------------------------------------------------------------------------------- /test/integration/fs/ide_write/README.md: -------------------------------------------------------------------------------- 1 | # FAT32 Test Service 2 | 3 | Test the functionalty of the FAT32 filesystem with the use of VirioBlk disk. 4 | 5 | The test verifies the following things: 6 | 7 | 1. The disk size. 8 | 2. Auto mounting/recognition of filesystem. 9 | 3. Disk structure. 10 | 4. Disk content with the help of `banana.txt` and `banana.ascii`. 11 | 5. Filesystem API (read) and subclasses as `Dirent`. 12 | 6. Remounting of filesystem. 13 | 7. Asynchronous operations (also nested like stat into read). 14 | 15 | `fat32_disk.sh` is used to create a 4 GB FAT32 disk `my.disk` with `banana.txt` as content, which will be included by qemu as a separate drive. 16 | 17 | -------------------------------------------------------------------------------- /deps/libfdt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | 3 | project(libfdt) 4 | 5 | set(SRC_S 6 | dtc/libfdt/fdt.c 7 | dtc/libfdt/fdt_ro.c 8 | dtc/libfdt/fdt_wip.c 9 | dtc/libfdt/fdt_sw.c 10 | dtc/libfdt/fdt_rw.c 11 | dtc/libfdt/fdt_strerror.c 12 | dtc/libfdt/fdt_empty_tree.c 13 | dtc/libfdt/fdt_addresses.c 14 | dtc/libfdt/fdt_overlay.c 15 | ) 16 | 17 | set(HEADERS 18 | dtc/libfdt/fdt.h 19 | dtc/libfdt/libfdt.h 20 | dtc/libfdt/libfdt_env.h 21 | ) 22 | 23 | include_directories(dtc/libfdt) 24 | 25 | add_library(fdt STATIC ${SRC_S}) 26 | 27 | INSTALL(TARGETS fdt DESTINATION "lib") 28 | 29 | INSTALL(FILES ${HEADERS} DESTINATION "include") 30 | -------------------------------------------------------------------------------- /deps/musl/patches/endian.patch: -------------------------------------------------------------------------------- 1 | diff --git a/include/endian.h b/include/endian.h 2 | index 1bd4445..88c3347 100644 3 | --- a/include/endian.h 4 | +++ b/include/endian.h 5 | @@ -29,12 +29,12 @@ static __inline uint16_t __bswap16(uint16_t __x) 6 | 7 | static __inline uint32_t __bswap32(uint32_t __x) 8 | { 9 | - return __x>>24 | __x>>8&0xff00 | __x<<8&0xff0000 | __x<<24; 10 | + return __x>>24 | (__x>>8&0xff00) | (__x<<8&0xff0000) | __x<<24; 11 | } 12 | 13 | static __inline uint64_t __bswap64(uint64_t __x) 14 | { 15 | - return __bswap32(__x)+0ULL<<32 | __bswap32(__x>>32); 16 | + return (__bswap32(__x)+0ULL)<<32 | __bswap32(__x>>32); 17 | } 18 | 19 | #if __BYTE_ORDER == __LITTLE_ENDIAN 20 | -------------------------------------------------------------------------------- /deps/lest/default.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs, 3 | stdenv 4 | }: 5 | stdenv.mkDerivation rec { 6 | pname = "lest"; 7 | version = "1.36.0"; 8 | 9 | meta = { 10 | description = "A tiny C++11 test framework – lest errors escape testing."; 11 | homepage = "https://github.com/martinmoene/lest"; 12 | license = pkgs.lib.licenses.boost; 13 | }; 14 | 15 | src = fetchGit { 16 | url = "https://github.com/martinmoene/lest.git"; 17 | ref = "refs/tags/v${version}"; 18 | rev = "57197f32f2c7d3f3d3664a9010d3ff181a40f6ca"; 19 | }; 20 | 21 | cmakeBuildType = "Debug"; 22 | 23 | postBuild = '' 24 | mkdir -p "$out/include" 25 | cp -r include "$out/" 26 | ''; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /test/integration/kernel/term/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from __future__ import print_function 3 | from builtins import str 4 | import sys 5 | import os 6 | import socket 7 | 8 | from vmrunner import vmrunner 9 | vm = vmrunner.vms[0] 10 | 11 | 12 | def begin_test(line): 13 | s = socket.socket() 14 | s.connect(("10.0.0.63", 23)) 15 | s.send(str.encode("netstat\r\n")) 16 | result = s.recv(1024).decode() 17 | print(result) 18 | s.close() 19 | return "Banana Terminal" in result 20 | 21 | vm.on_output("Connect to terminal", begin_test) 22 | if len(sys.argv) > 1: 23 | vm.boot(image_name=str(sys.argv[1])) 24 | else: 25 | vm.boot(40,image_name='kernel_term.elf.bin') 26 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { withCcache ? false, # Enable ccache. Requires correct permissions, see overlay.nix. 2 | smp ? false, # Enable multcore support (SMP) 3 | nixpkgs ? ./pinned.nix, 4 | overlays ? [ 5 | (import ./overlay.nix { inherit withCcache; inherit smp; disableTargetWarning = true; } ) 6 | ], 7 | pkgs ? import nixpkgs { config = {}; inherit overlays; } 8 | }: 9 | 10 | let 11 | inherit (pkgs) pkgsIncludeOS; 12 | in 13 | assert (pkgsIncludeOS.stdenv.buildPlatform.isLinux == false) -> 14 | throw "Currently only Linux builds are supported"; 15 | assert (pkgsIncludeOS.stdenv.hostPlatform.isMusl == false) -> 16 | throw "Stdenv should be based on Musl"; 17 | 18 | pkgsIncludeOS.includeos 19 | -------------------------------------------------------------------------------- /src/net/ip6/packet_mld.cpp: -------------------------------------------------------------------------------- 1 | //#define MLD_DEBUG 1 2 | #ifdef MLD_DEBUG 3 | #define PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__) 4 | #else 5 | #define PRINT(fmt, ...) /* fmt */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace net::mld 13 | { 14 | MldPacket2::MldPacket2(icmp6::Packet& icmp6) : icmp6_(icmp6) {} 15 | 16 | MldPacket2::Query& MldPacket2::query() 17 | { 18 | return *reinterpret_cast(&(icmp6_.header().payload[0])); 19 | } 20 | 21 | MldPacket2::Report& MldPacket2::report() 22 | { 23 | return *reinterpret_cast(&(icmp6_.header().payload[0])); 24 | } 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /api/fuzz/fuzzy_stack.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace fuzzy 7 | { 8 | using AsyncDevice = hw::Async_device; 9 | using AsyncDevice_ptr = std::unique_ptr; 10 | 11 | enum layer_t { 12 | ETH, 13 | IP4, 14 | TCP, 15 | TCP_CONNECTION, 16 | UDP, 17 | DNS, 18 | HTTP, 19 | WEBSOCKET 20 | }; 21 | 22 | struct stack_config { 23 | layer_t layer = IP4; 24 | uint16_t ip_port = 0; 25 | }; 26 | 27 | extern void 28 | insert_into_stack(AsyncDevice_ptr&, stack_config config, 29 | const uint8_t* data, const size_t size); 30 | } 31 | -------------------------------------------------------------------------------- /lib/LiveUpdate/README.md: -------------------------------------------------------------------------------- 1 | # LiveUpdate 2 | 3 | # Put Liveupdate in conan editable mode 4 | 5 | **NOTE: Make sure you are in the IncludeOS src directory** 6 | 1. Remove the version variable from the `conanfile.py`. 7 | ``` 8 | awk '!/version = conan_tools/' lib/LiveUpdate/conanfile.py > temp && mv temp lib/LiveUpdate/conanfile.py 9 | ``` 10 | 1. Add editable package with correct layout 11 | ``` 12 | conan editable add lib/LiveUpdate liveupdate/9.9.9@includeos/latest --layout lib/LiveUpdate/layout.txt 13 | ``` 14 | 1. Run Conan install 15 | ``` 16 | conan install -if lib/LiveUpdate/build lib/LiveUpdate 17 | ``` 18 | 1. Run Conan build 19 | ``` 20 | conan build -sf . -bf lib/LiveUpdate/build lib/LiveUpdate 21 | ``` 22 | -------------------------------------------------------------------------------- /test/integration/fs/ide/banana.ascii: -------------------------------------------------------------------------------- 1 | const std::string internal_banana= 2 | R"( ____ ___ 3 | | _ \ ___ _ _.' _ `. 4 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 5 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 6 | | `.[_) ) _ | \| | (_) | | | | |.',..| 7 | ':. `. /| | | | | _ | |\ | | |.' :;::' 8 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 9 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 10 | ';:' `::;::;' '' ., . 11 | `: .,. `' .::... . .::;::;' 12 | `..:;::;:.. ::;::;:;:;, :;::;' 13 | "-:;::;:;: ':;::;:'' ;.-' 14 | ""`---...________...---'"" 15 | )"; 16 | -------------------------------------------------------------------------------- /test/integration/kernel/stacktrace/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from builtins import str 4 | import sys 5 | import os 6 | 7 | from vmrunner import vmrunner 8 | 9 | vm = vmrunner.vms[0] 10 | 11 | counter = 0 12 | expected = 4 13 | def is_good(line): 14 | global counter, expected 15 | counter += 1 16 | print(" Found expected line {}/{}\n".format(counter, expected, line)) 17 | if (counter == expected): 18 | vm.exit(0, "All tests passed") 19 | 20 | vm.on_output("Service::start()", is_good) 21 | vm.on_output("kernel_main", is_good) 22 | vm.on_output("libc_start_main", is_good) 23 | vm.on_output("long_mode", is_good) 24 | 25 | vm.boot(20,image_name='kernel_stacktrace') 26 | -------------------------------------------------------------------------------- /test/userspace/fuzz/macfuzzy.hpp: -------------------------------------------------------------------------------- 1 | // __ __ ___ _ _ 2 | // | \/ | __ _ __ | __| _ _ ___ ___ | || | 3 | // | |\/| | / _` | / _| | _| | +| | |_ / |_ / \_, | 4 | // |_|__|_| \__,_| \__|_ _|_|_ \_,_| _/__| _/__| _|__/ 5 | // _|"""""|_|"""""|_|"""""|_| """ |_|"""""|_|"""""|_|"""""|_| """"| 6 | // "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' 7 | #pragma once 8 | #include "fuzzy_helpers.hpp" 9 | #include "fuzzy_stack.hpp" 10 | #include "fuzzy_packet.hpp" 11 | //#include "fuzzy_stream.hpp" 12 | extern void fuzzy_http(const uint8_t*, size_t); 13 | extern void fuzzy_websocket(const uint8_t*, size_t); 14 | -------------------------------------------------------------------------------- /test/integration/fs/fat16/banana.ascii: -------------------------------------------------------------------------------- 1 | const std::string internal_banana= 2 | R"( ____ ___ 3 | | _ \ ___ _ _.' _ `. 4 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 5 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 6 | | `.[_) ) _ | \| | (_) | | | | |.',..| 7 | ':. `. /| | | | | _ | |\ | | |.' :;::' 8 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 9 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 10 | ';:' `::;::;' '' ., . 11 | `: .,. `' .::... . .::;::;' 12 | `..:;::;:.. ::;::;:;:;, :;::;' 13 | "-:;::;:;: ':;::;:'' ;.-' 14 | ""`---...________...---'"" 15 | )"; 16 | -------------------------------------------------------------------------------- /test/integration/fs/fat32/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5 2 | )set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(service) 5 | include(os) 6 | 7 | os_add_executable(fs_fat32 "FAT32 filesystem test" fat32.cpp) 8 | os_add_stdout(fs_fat32 default_stdout) 9 | 10 | if ("$ENV{PLATFORM}" STREQUAL "x86_solo5") 11 | os_add_drivers(fs_fat32 solo5blk) 12 | else() 13 | os_add_drivers(fs_fat32 virtioblk) 14 | endif() 15 | 16 | #do this code in cmake instead ? 17 | configure_file(fat32_disk.sh ${CMAKE_CURRENT_BINARY_DIR}) 18 | configure_file(banana.txt ${CMAKE_CURRENT_BINARY_DIR}) 19 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 20 | configure_file(vm.json ${CMAKE_CURRENT_BINARY_DIR}) 21 | -------------------------------------------------------------------------------- /test/integration/fs/fat32/banana.ascii: -------------------------------------------------------------------------------- 1 | const std::string internal_banana= 2 | R"( ____ ___ 3 | | _ \ ___ _ _.' _ `. 4 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 5 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 6 | | `.[_) ) _ | \| | (_) | | | | |.',..| 7 | ':. `. /| | | | | _ | |\ | | |.' :;::' 8 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 9 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 10 | ';:' `::;::;' '' ., . 11 | `: .,. `' .::... . .::;::;' 12 | `..:;::;:.. ::;::;:;:;, :;::;' 13 | "-:;::;:;: ':;::;:'' ;.-' 14 | ""`---...________...---'"" 15 | )"; 16 | -------------------------------------------------------------------------------- /src/platform/x86_solo5/serial1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern "C" { 6 | #include 7 | 8 | void __init_serial1() {} 9 | 10 | void __serial_print1(const char* cstr) 11 | { 12 | solo5_console_write(cstr, strlen(cstr)); 13 | } 14 | void __serial_print(const char* str, size_t len) 15 | { 16 | solo5_console_write(str, len); 17 | } 18 | 19 | void kprint(const char* c){ 20 | __serial_print1(c); 21 | } 22 | 23 | void kprintf(const char* format, ...) 24 | { 25 | char buf[8192]; 26 | va_list aptr; 27 | va_start(aptr, format); 28 | vsnprintf(buf, sizeof(buf), format, aptr); 29 | __serial_print1(buf); 30 | va_end(aptr); 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /test/integration/fs/ide_write/banana.ascii: -------------------------------------------------------------------------------- 1 | const std::string internal_banana= 2 | R"( ____ ___ 3 | | _ \ ___ _ _.' _ `. 4 | _ | [_) )' _ `._ _ ___ ! \ | | (_) | _ 5 | |:;.| _ <| (_) | \ | |' _ `| \| | _ | .:;| 6 | | `.[_) ) _ | \| | (_) | | | | |.',..| 7 | ':. `. /| | | | | _ | |\ | | |.' :;::' 8 | !::, `-!_| | | |\ | | | | | \ !_!.' ':;! 9 | !::; ":;:!.!.\_!_!_!.!-'-':;:'' '''! 10 | ';:' `::;::;' '' ., . 11 | `: .,. `' .::... . .::;::;' 12 | `..:;::;:.. ::;::;:;:;, :;::;' 13 | "-:;::;:;: ':;::;:'' ;.-' 14 | ""`---...________...---'"" 15 | )"; 16 | -------------------------------------------------------------------------------- /test/integration/kernel/plugin_init/plugin1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern bool example_plugin_registered; 4 | extern bool example_plugin_run; 5 | int my_plugin_functions = 0; 6 | int f1_data = 0; 7 | 8 | __attribute__((constructor)) 9 | static void func1(){ 10 | 11 | 12 | // NOTE: since this plugin is a part of the service, its ctors 13 | // will be called after the installed plugin ctors. Therefore we can 14 | // depend on installed plugins being run / registered. 15 | 16 | CHECKSERT(example_plugin_registered, "Example plugin registered"); 17 | CHECKSERT(example_plugin_run, "Example plugin ran"); 18 | 19 | INFO("Plugin 1","initialization function 1"); 20 | f1_data = 0xf1; 21 | my_plugin_functions++; 22 | } 23 | -------------------------------------------------------------------------------- /test/unit/kernel/blocking.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | extern "C" uint32_t os_get_blocking_level(); 5 | extern "C" uint32_t os_get_highest_blocking_level(); 6 | 7 | CASE("OS::block") 8 | { 9 | static bool event_happened = false; 10 | auto ev = Events::get().subscribe( 11 | [&] () { 12 | event_happened = true; 13 | EXPECT(os_get_blocking_level() == 1); 14 | EXPECT(os_get_highest_blocking_level() == 1); 15 | }); 16 | Events::get().trigger_event(ev); 17 | // block until event happens 18 | os::block(); 19 | // Done 20 | EXPECT(event_happened); 21 | EXPECT(os_get_blocking_level() == 0); 22 | EXPECT(os_get_highest_blocking_level() == 1); 23 | } 24 | -------------------------------------------------------------------------------- /src/chainload/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | # IncludeOS install location 4 | project(chainloader C CXX) 5 | 6 | find_package(IncludeOS REQUIRED) 7 | find_package(fmt CONFIG REQUIRED) 8 | 9 | set(ARCH i686) 10 | set(PLATFORM nano) 11 | set(ELF_SYMBOLS true) 12 | 13 | include(os) 14 | 15 | option(default_stdout "" ON) 16 | set(SOURCES 17 | service.cpp hotswap.cpp 18 | ) 19 | set(BINARY_NAME chainloader) 20 | 21 | os_add_executable(chainloader "IncludeOS chainloader" ${SOURCES}) 22 | os_install(TARGETS chainloader DESTINATION bin) 23 | os_install(TARGETS chainloader.elf.bin.copy DESTINATION bin) 24 | os_install(TARGETS _elf_symbols.bin DESTINATION bin) 25 | -------------------------------------------------------------------------------- /test/userspace/websockets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | # Human-readable name of your service 8 | set(SERVICE_NAME "Linux userspace WebSocket test") 9 | 10 | # Name of your service binary 11 | set(BINARY "websockets") 12 | 13 | # Source files to be linked with OS library parts to form bootable image 14 | set(SOURCES 15 | service.cpp 16 | ) 17 | 18 | set(EXTRA_LIBS 19 | $ENV{INCLUDEOS_PREFIX}/includeos/x86_64/lib/libcrypto.a 20 | $ENV{INCLUDEOS_PREFIX}/includeos/x86_64/lib/libssl.a 21 | -ldl 22 | ) 23 | 24 | include($ENV{INCLUDEOS_PREFIX}/includeos/linux.service.cmake) 25 | -------------------------------------------------------------------------------- /api/fuzz/fuzzy_packet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "fuzzy_helpers.hpp" 5 | 6 | namespace fuzzy 7 | { 8 | extern uint8_t* 9 | add_eth_layer(uint8_t* data, FuzzyIterator& fuzzer, net::Ethertype type); 10 | extern uint8_t* 11 | add_ip4_layer(uint8_t* data, FuzzyIterator& fuzzer, 12 | const net::ip4::Addr src_addr, 13 | const net::ip4::Addr dst_addr, 14 | const uint8_t protocol = 0); 15 | extern uint8_t* 16 | add_udp4_layer(uint8_t* data, FuzzyIterator& fuzzer, 17 | const uint16_t dport); 18 | extern uint8_t* 19 | add_tcp4_layer(uint8_t* data, FuzzyIterator& fuzzer, 20 | const uint16_t dport); 21 | } -------------------------------------------------------------------------------- /test/integration/kernel/exception/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from builtins import str 3 | import sys 4 | import os 5 | import socket 6 | 7 | from vmrunner import vmrunner 8 | vm = vmrunner.vms[0] 9 | 10 | counter = 0 11 | expected = 5 12 | def is_good(line): 13 | global counter 14 | counter += 1 15 | print(" Found expected line {}/{}\n".format(counter, expected, line)) 16 | 17 | if (counter == expected): 18 | vm.exit(0, "All tests passed") 19 | 20 | vm.on_output("\\x15\\x07\\t\*\*\*\* PANIC \*\*\*\*", is_good) 21 | vm.on_output("Divide-by-zero Error", is_good) 22 | 23 | vm.on_output("__cpu_exception", is_good) 24 | vm.on_output("Service::start()", is_good) 25 | 26 | vm.boot(20,image_name='kernel_exception') 27 | -------------------------------------------------------------------------------- /src/musl/dup3.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | #include 4 | 5 | static long sys_dup(int /*oldfd*/) 6 | { 7 | return -ENOSYS; 8 | } 9 | static long sys_dup2(int /*oldfd*/, int /*newfd*/) 10 | { 11 | return -ENOSYS; 12 | } 13 | static long sys_dup3(int /*oldfd*/, int /*newfd*/, int /*flags*/) 14 | { 15 | return -ENOSYS; 16 | } 17 | 18 | extern "C" 19 | long syscall_SYS_dup(int oldfd) { 20 | return strace(sys_dup, "dup", oldfd); 21 | } 22 | 23 | extern "C" 24 | long syscall_SYS_dup2(int oldfd, int newfd) { 25 | return strace(sys_dup2, "dup2", oldfd, newfd); 26 | } 27 | 28 | extern "C" 29 | long syscall_SYS_dup3(int oldfd, int newfd, int flags) { 30 | return strace(sys_dup3, "dup3", oldfd, newfd, flags); 31 | } 32 | -------------------------------------------------------------------------------- /src/musl/kill.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | #include 3 | 4 | int sys_kill(pid_t /*pid*/, int /*sig*/) { 5 | os::panic("KILL called"); 6 | } 7 | 8 | int sys_tkill(int /*tid*/, int /*sig*/) { 9 | os::panic("TKILL called"); 10 | } 11 | 12 | int sys_tgkill(int /*tgid*/, int /*tid*/, int /*sig*/) { 13 | os::panic("TGKILL called"); 14 | } 15 | 16 | extern "C" 17 | long syscall_SYS_kill(pid_t pid, int sig) { 18 | return strace(sys_kill, "kill", pid, sig); 19 | } 20 | 21 | extern "C" 22 | long syscall_SYS_tkill(int tid, int sig) { 23 | return strace(sys_tkill, "tkill", tid, sig); 24 | } 25 | 26 | extern "C" 27 | long syscall_SYS_tgkill(int tgid, int tid, int sig) 28 | { 29 | return strace(sys_tgkill, "tgkill", tgid, tid, sig); 30 | } 31 | -------------------------------------------------------------------------------- /test/integration/net/icmp6/linux/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export GPROF="OFF" 6 | export DBG="OFF" 7 | 8 | export num_jobs=${num_jobs:--j32} 9 | 10 | function make_linux(){ 11 | pushd $INCLUDEOS_SRC/linux/build 12 | cmake -DGPROF=$GPROF -DDEBUGGING=$DBG .. 13 | make $num_jobs install 14 | popd 15 | } 16 | 17 | function make_service(){ 18 | mkdir -p build 19 | pushd build 20 | cmake -DGPROF=$GPROF -DDEBUGGING=$DBG .. 21 | make $num_jobs 22 | popd 23 | } 24 | 25 | if [ -z "$1" ] 26 | then 27 | GPROF="OFF" 28 | elif [ "$1" == "gprof" ] 29 | then 30 | GPROF="ON" 31 | fi 32 | 33 | 34 | make_linux 35 | make_service 36 | 37 | #sudo mknod /dev/net/tap c 10 200 38 | BINARY=build/"`cat build/binary.txt`" 39 | sudo $BINARY 40 | -------------------------------------------------------------------------------- /test/integration/net/tcp/linux/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export GPROF="OFF" 6 | export DBG="OFF" 7 | 8 | export num_jobs=${num_jobs:--j32} 9 | 10 | function make_linux(){ 11 | pushd $INCLUDEOS_SRC/linux/build 12 | cmake -DGPROF=$GPROF -DDEBUGGING=$DBG .. 13 | make $num_jobs install 14 | popd 15 | } 16 | 17 | function make_service(){ 18 | mkdir -p build 19 | pushd build 20 | cmake -DGPROF=$GPROF -DDEBUGGING=$DBG .. 21 | make $num_jobs 22 | popd 23 | } 24 | 25 | if [ -z "$1" ] 26 | then 27 | GPROF="OFF" 28 | elif [ "$1" == "gprof" ] 29 | then 30 | GPROF="ON" 31 | fi 32 | 33 | 34 | make_linux 35 | make_service 36 | 37 | #sudo mknod /dev/net/tap c 10 200 38 | BINARY=build/"`cat build/binary.txt`" 39 | sudo $BINARY 40 | -------------------------------------------------------------------------------- /test/integration/hw/serial/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from __future__ import print_function 4 | import sys 5 | import os 6 | 7 | includeos_src = os.environ.get('INCLUDEOS_SRC', 8 | os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))).split('/test')[0]) 9 | sys.path.insert(0,includeos_src) 10 | 11 | from subprocess import call 12 | 13 | from vmrunner import vmrunner 14 | 15 | # Get an auto-created VM from the vmrunner 16 | vm = vmrunner.vms[0] 17 | 18 | def test_serial_port(): 19 | print(" Test triggered") 20 | global vm 21 | vm.writeline("Here is a test\n") 22 | 23 | 24 | vm.on_output("trigger_test_serial_port", test_serial_port) 25 | 26 | # Boot the VM 27 | vm.make().boot(80) 28 | -------------------------------------------------------------------------------- /test/integration/fs/vfs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) 3 | 4 | project(vfs) 5 | include(os) 6 | 7 | os_add_executable(fs_vfs "VFS filesystem test" service.cpp) 8 | os_add_stdout(fs_vfs default_stdout) 9 | os_add_drivers(fs_vfs virtioblk) 10 | os_diskbuilder(fs_vfs memdisk) 11 | 12 | #do this code in cmake instead ? 13 | file(COPY memdisk DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 14 | file(COPY virtio1 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 15 | file(COPY virtio2 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 16 | file(COPY create_disk.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 17 | 18 | configure_file(test.py ${CMAKE_CURRENT_BINARY_DIR}) 19 | configure_file(vm.json ${CMAKE_CURRENT_BINARY_DIR}) 20 | -------------------------------------------------------------------------------- /test/userspace/fuzz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.31.6) 2 | if (NOT DEFINED ENV{INCLUDEOS_PREFIX}) 3 | set(ENV{INCLUDEOS_PREFIX} /usr/local) 4 | endif() 5 | project (service C CXX) 6 | 7 | set(SERVICE_NAME "Linux userspace IP-stack fuzzer") 8 | set(BINARY "linux_fuzz") 9 | 10 | set(SOURCES 11 | service.cpp fuzzy_packet.cpp fuzzy_stack.cpp fuzzy_webserver.cpp http.cpp 12 | ) 13 | 14 | #option(LIBCPP "" ON) 15 | option(LIBFUZZER "" ON) 16 | option(SANITIZE "" ON) 17 | option(ENABLE_LTO "" OFF) # disable LTO because so much issues with LLD 18 | option(STATIC_BUILD "" OFF) # asan doesnt support static builds 19 | option(STRIP_BINARY "" OFF) # we need to see symbol names 20 | 21 | include($ENV{INCLUDEOS_PREFIX}/cmake/linux.service.cmake) 22 | -------------------------------------------------------------------------------- /src/musl/ioctl.cpp: -------------------------------------------------------------------------------- 1 | #include "common.hpp" 2 | 3 | #include 4 | #include 5 | 6 | static long sys_ioctl(int fd, int req, void* arg) { 7 | if (fd == 1 or fd == 2) { 8 | if (req == TIOCGWINSZ) { 9 | winsize* ws = (winsize*)arg; 10 | ws->ws_row = 25; 11 | ws->ws_col = 80; 12 | return 0; 13 | } 14 | 15 | if (req == TIOCSWINSZ) { 16 | const auto* ws = (winsize*) arg; 17 | (void) ws; 18 | } 19 | 20 | return 0; 21 | } 22 | 23 | if(auto* fildes = FD_map::_get(fd); fildes) 24 | return fildes->ioctl(req, arg); 25 | 26 | return -EBADF; 27 | } 28 | 29 | extern "C" 30 | long syscall_SYS_ioctl(int fd, int req, void* arg) { 31 | return strace(sys_ioctl, "ioctl", fd, req, arg); 32 | } 33 | --------------------------------------------------------------------------------