KernelTestFramework / ktf

Licence: BSD-2-Clause license
Kernel Test Framework

Programming Languages

c
50402 projects - #5 most used programming language
assembly
5116 projects
Makefile
30231 projects

Projects that are alternatives of or similar to ktf

Toaruos
A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
Stars: ✭ 4,687 (+3649.6%)
Mutual labels:  kernel, x86-64, os, smp
novusk
A kernel written in Rust
Stars: ✭ 61 (-51.2%)
Mutual labels:  kernel, x86-64, os
chaos-2
A hand-made SMP-aware kernel
Stars: ✭ 20 (-84%)
Mutual labels:  kernel, os, smp
pranaOS
A unix operating system written from scratch in c that gives support for arm, x86
Stars: ✭ 138 (+10.4%)
Mutual labels:  kernel, x86-64, os
biefircate
Running x86-16 or x86-32 code from x86-64 UEFI; _very experimental_ • mirror of https://gitlab.com/tkchia/biefircate • developer notes at https://gitlab.com/tkchia/biefircate/-/blob/main/doc/NOTES.asciidoc
Stars: ✭ 47 (-62.4%)
Mutual labels:  kernel, x86-64, os
misaka
Experimental x86_64 kernel project. Planned eventual successor to the kernel in ToaruOS. WIP
Stars: ✭ 82 (-34.4%)
Mutual labels:  kernel, x86-64, smp
ByteOS
A simple hobby operating system for the x86-64 architecture, written in C.
Stars: ✭ 47 (-62.4%)
Mutual labels:  kernel, x86-64, os
KnutOS
An x86_64 hobbyist OS written in C and Assembly
Stars: ✭ 16 (-87.2%)
Mutual labels:  kernel, x86-64, os
Dennix
Dennix is a unix-like hobbyist operating system written from scratch.
Stars: ✭ 53 (-57.6%)
Mutual labels:  kernel, x86-64, os
Os2
x86_64 OS kernel with completely async userspace and single address space [WIP; but basic kernel functionality implemented]
Stars: ✭ 25 (-80%)
Mutual labels:  kernel, x86-64, os
Wingos
a little 64bit operating system written in c++ with smp support
Stars: ✭ 361 (+188.8%)
Mutual labels:  kernel, x86-64, os
Monkos
an experimental 64-bit operating system
Stars: ✭ 100 (-20%)
Mutual labels:  kernel, x86-64, os
Ktf
Kernel Test Framework
Stars: ✭ 93 (-25.6%)
Mutual labels:  kernel, x86-64, os
Cyjon
A simple, clean code, multi-tasking operating system written in pure assembly language for 64-bit processors from the AMD64 family.
Stars: ✭ 184 (+47.2%)
Mutual labels:  kernel, x86-64, os
SynapseOS
SynapseOS - модульная операционная система на языке C.
Stars: ✭ 93 (-25.6%)
Mutual labels:  kernel, os
SynnixOS
Hobbyist Operating System targeting x86_64 systems. Includes userspace, Virtual File System, An InitFS (tarfs), Lua port, easy porting, a decent LibC and LibM, and a shell that supports: piping, file redirection, and more.
Stars: ✭ 40 (-68%)
Mutual labels:  kernel, x86-64
disfetch
Yet another *nix distro fetching program, but less complex.
Stars: ✭ 45 (-64%)
Mutual labels:  kernel, os
Macaron
A sweet hobby made operating system written in C++ for x86 CPUs with GUI
Stars: ✭ 34 (-72.8%)
Mutual labels:  kernel, os
FoxOS
The FoxOS main repository
Stars: ✭ 48 (-61.6%)
Mutual labels:  x86-64, os
Cardinal
Operating system designed to be fast and secure.
Stars: ✭ 20 (-84%)
Mutual labels:  kernel, os

KTF - Kernel Test Framework

GitHub release C/C++ CI Docker Build Test test-clang-format Total alerts Language grade: C/C++

KTF is a small and simple OS kernel, that enables writing low-level software tests for supported machine architectures (currently: x86-64).

Features overview

  • Machine architecture: x86-64, x86-32 in the baking
  • SMP support with basic Per-CPU pages
  • (very) Basic Physical Memory Management (PMM) and Virtual Memory Management (VMM)
  • Very basic slab allocator
  • Local APIC support
  • Initial MP tables parsing
  • Basic ACPI tables parsing
  • Simple UART driver
  • (very) Simple VGA driver

Some more features are in the making. Check out the issues.

Getting Started

The quick start is to run the following commands. The content of the file tests/test.c will be executed. Note, the last command will block.

Build a boot.iso from scratch, in the docker container.

make clean
make docker:boot.iso

Boot the resulting image:

make boot

Build instructions

Requirements

You may need to install the following (unless you already have it):

  • GRUB2 bootloader tools - grub2-common package (e.g. apt install grub2-common)
  • ISO generation tools - xorriso package (e.g. apt install xorriso)

Kernel image build (for example to be used with QEMU)

  • Native
make
  • Docker
make docker:all

bootable ISO generation (for example to boot KTF as a guest under Xen or on a bare-metal machine)

  • Native
make boot.iso
  • Docker
make docker:boot.iso

The make command generates the kernel64.bin multiboot-compatible ELF file, that you can directly boot with QEMU. The make boot.iso command takes the kernel64.bin, places it in grub/boot/ directory hierarchy and generates a boot.iso out of the grub/ (using grub/boot/grub/grub.cfg as a default GRUB config).

Fedora

KTF builds and runs on Fedora, but you will need to tweak some of the commands. Create a Makeconf.local file with the following content (tested with Fedora 32):

DIST=$(shell grep NAME= /etc/os-release | cut -d= -f2)
ifeq ($(DIST),Fedora)
GRUB_FILE := grub2-file
GRUB_MKIMAGE := grub2-mkimage
GRUB_MODULES += normal
QEMU_BIN := qemu-kvm
DOCKER_MOUNT_OPTS := :Z
endif

Running the kernel

QEMU (KVM or not)

Main Makefile has several targets that make booting KTF with QEMU easier. The Makefile detects if the host system is linux and enables KVM support if so. Default parameters for QEMU can be found in the Makefile under QEMU_PARAMS variable.

For booting run:

make boot

For debugging ISO run:

make boot_debug

For debugging kernel image run:

make debug

Xen guest

Use the following guest domain config example for booting KTF with Xen:

name="kernel64"
builder="hvm"
memory=1024

serial= [ 'file:/tmp/kernel.log', 'pty' ]

disk = [ '/home/user/boot.iso,,hdc,cdrom' ]

on_reboot = "destroy"

vcpus=1

You need to generate a bootable ISO for this.

Adding new tests

New tests can be added by adding a new function in a file in the tests folder. Each test signature must be the same as test_fn provided in test.h. Tests can be enabled in grub.cfg by adding the option with key tests and values the comma-separated list of function names, such as tests=test1,test2,unit_tests.

Style

The style for this project is defined in .clang-format file in the main directory of this repository.

Use the following command to apply the style automatically to the file you modify:

clang-format -style=file -Werror -i MODIFIED_FILE

For more information refer to: https://clang.llvm.org/docs/ClangFormat.html

This project uses https://github.com/DoozyX/clang-format-lint-action action workflow to detect style mismatches automatically. For more information refer to: https://github.com/marketplace/actions/clang-format-lint

Running the clang-format workflow locally

Build clang-format-lint container

docker build -t clang-format-lint github.com/DoozyX/clang-format-lint-action

This has to be done only once.

Patch your files

make style

Running the one-line-scan workflow locally

Build the ktf-one-line-scan container

  • first, download the one-line-scan base image
docker build -t one-line-scan \
    https://raw.githubusercontent.com/awslabs/one-line-scan/master/tools/Dockerfile
  • create the KTF specific one-line-scan image, including necessary tools for building
 docker build -t ktf-one-line-scan \
    --build-arg USER_ID=$(id -u) \
    --build-arg GROUP_ID=$(id -g) \
    --build-arg USER=$USER \
    --file tools/docker/OnelineScanDockerfile .

This has to be done only once.

Scan your current working directory

  • per default, one-line-scan scans against the diff between HEAD and origin/mainline commit
make onelinescan

Credits and Attributions

  • Parts of the KTF project are inspired by and based on XTF project [1] developed by Andrew Cooper of Citrix.

[1] http://xenbits.xenproject.org/docs/xtf/

Security

See CONTRIBUTING for more information.

Community

Maintainers and users of KTF communicate in Slack. We set up a Slack workspace and we're actively sharing ideas, bugs and anything related to KTF there. Feel free to join us: Slack invite link

License

GitHub

This project is licensed under the BSD 2-Clause License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].