Skip to content

Commit

Permalink
Merge branch 'release/v0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Galfurian committed Apr 5, 2024
2 parents ee2f95e + f9679f2 commit 0db5c73
Show file tree
Hide file tree
Showing 136 changed files with 5,548 additions and 2,172 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,23 @@ jobs:
run: |
cmake -B build
cmake --build build --parallel 2
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install test dependencies
run: |
sudo apt-get update
sudo apt-get install -y nasm qemu-system-x86 mtools
- name: Run tests
run: |
cmake -B build -DEMULATOR_OUTPUT_TYPE=OUTPUT_LOG
cmake --build build --parallel 2 --target filesystem cdrom_test.iso qemu-test
- name: Check
run: |
cat build/test.log | scripts/tapview || cat build/test.log build/serial.log
60 changes: 42 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ else()
set(CMAKE_LINKER ld)
endif()

# =============================================================================
# EMULATION SERIAL OUTPUT OPTION
# =============================================================================
# Set the list of valid emulator output options.
set(EMULATOR_OUTPUT_TYPES OUTPUT_STDIO OUTPUT_LOG)
# Add the emulator output option.
set(EMULATOR_OUTPUT_TYPE "OUTPUT_STDIO" CACHE STRING "Chose the type of emulator output: ${EMULATOR_OUTPUT_TYPES}")
# List of emulator output options.
set_property(CACHE EMULATOR_OUTPUT_TYPE PROPERTY STRINGS ${EMULATOR_OUTPUT_TYPES})
# Check which emulator output option is currently active.
list(FIND EMULATOR_OUTPUT_TYPES ${EMULATOR_OUTPUT_TYPE} INDEX)
if(index EQUAL -1)
message(FATAL_ERROR "Emulator output type ${EMULATOR_OUTPUT_TYPE} is not valid.")
else()
message(STATUS "Setting emulator output type to ${EMULATOR_OUTPUT_TYPE}.")
endif()

# =============================================================================
# ASSEMBLY COMPILER
# =============================================================================
Expand Down Expand Up @@ -152,23 +169,6 @@ add_custom_target(filesystem
DEPENDS programs tests
)

# =============================================================================
# EMULATION SERIAL OUTPUT OPTION
# =============================================================================
# Set the list of valid emulator output options.
set(EMULATOR_OUTPUT_TYPES OUTPUT_STDIO OUTPUT_LOG)
# Add the emulator output option.
set(EMULATOR_OUTPUT_TYPE "OUTPUT_STDIO" CACHE STRING "Chose the type of emulator output: ${EMULATOR_OUTPUT_TYPES}")
# List of emulator output options.
set_property(CACHE EMULATOR_OUTPUT_TYPE PROPERTY STRINGS ${EMULATOR_OUTPUT_TYPES})
# Check which emulator output option is currently active.
list(FIND EMULATOR_OUTPUT_TYPES ${EMULATOR_OUTPUT_TYPE} INDEX)
if(index EQUAL -1)
message(FATAL_ERROR "Emulator output type ${EMULATOR_OUTPUT_TYPE} is not valid.")
else()
message(STATUS "Setting emulator output type to ${EMULATOR_OUTPUT_TYPE}.")
endif()

# =============================================================================
# EMULATOR CONFIGURATION
# =============================================================================
Expand Down Expand Up @@ -264,4 +264,28 @@ add_custom_target(
qemu-grub
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -boot d -cdrom ${CMAKE_BINARY_DIR}/cdrom.iso
DEPENDS cdrom.iso
)
)

# =============================================================================
# Booting with QEMU+GRUB for testing
# =============================================================================

# First, we need to build the ISO for the cdrom. It has a slightly different
# kernel command line including 'test'.
add_custom_target(
cdrom_test.iso
COMMAND cp -rf ${CMAKE_SOURCE_DIR}/iso .
COMMAND mv ${CMAKE_BINARY_DIR}/iso/boot/grub/grub.cfg.runtests ${CMAKE_BINARY_DIR}/iso/boot/grub/grub.cfg
COMMAND cp ${CMAKE_BINARY_DIR}/mentos/bootloader.bin ${CMAKE_BINARY_DIR}/iso/boot
COMMAND grub-mkrescue -o ${CMAKE_BINARY_DIR}/cdrom_test.iso ${CMAKE_BINARY_DIR}/iso
DEPENDS bootloader.bin
)

# This target runs the emulator, and executes the runtests binary as init process.
# Additionally it passes the '-device isa-debug-exit' option to shutdown qemu
# after the tests are done.
add_custom_target(
qemu-test
COMMAND ${EMULATOR} ${EMULATOR_FLAGS} -serial file:${CMAKE_BINARY_DIR}/test.log -nographic -device isa-debug-exit -boot d -cdrom ${CMAKE_BINARY_DIR}/cdrom_test.iso
DEPENDS cdrom_test.iso
)
329 changes: 164 additions & 165 deletions doc/syscall.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions files/etc/passwd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
root:root:0:0:Root User:/root:/bin/shell
user:user:1000:1000:Normal User:/home/user:/bin/shell
root:x:0:0:Root User:/root:/bin/shell
user:x:1000:1000:Normal User:/home/user:/bin/shell
2 changes: 2 additions & 0 deletions files/etc/shadow
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
root:33ba1bde6222ff5836cfe0123c71e594238e675a5a5b6fbfd2ad69ae7d580a40:::::::
user:35047cb1b06dabc31ce3f11b3cd0f83f7c2ed4d52851e62585906d44775a70a6:::::::
1 change: 1 addition & 0 deletions files/home/user/root
2 changes: 1 addition & 1 deletion files/usr/share/man/cat.man
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ DESCRIPTION
Prints the content of the given file.

OPTIONS
-h --help : shows command help.
-h, --help shows command help.
22 changes: 22 additions & 0 deletions files/usr/share/man/chmod.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SYNOPSIS
chmod MODE FILE

DESCRIPTION
chmod changes the file mode bits of the given file according to mode, which
must be an octal number representing the bit pattern for the new mode bits.

The numeric mode is from one to four octal digits (0-7), derived by adding
up the bits with values 4, 2, and 1. Omitted digits are assumed to be
leading zeros. The first digit selects the set user ID (4) and set group
ID (2) and restricted deletion or sticky (1) attributes. The second digit
selects permissions for the user who owns the file: read (4), write (2),
and execute (1); the third selects permissions for other users in the file's
group, with the same values; and the fourth for other users not in the
file's group, with the same values.

chmod never changes the permissions of symbolic links; the chmod system call
cannot change their permissions.

EXAMPLES
chmod 555 executable
Changes the mode bits of executable to r-xr-xr-x.
19 changes: 19 additions & 0 deletions files/usr/share/man/chown.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SYNOPSIS
chown [OWNER][:[GROUP]] FILE

DESCRIPTION
chown changes the user and/or group ownership of the given file.
If only a owner is given the file's group is not changed. If the owner
is followed by a colon and a group name (or numeric group ID), the group
ownership is changed as well. If the colon and group are given, but the
owner is omitted, only the group of the file is changed.

chown never changes the ownership of symbolic links; the chown system call
cannot change their ownership.

EXAMPLES
chown root /u
Change the owner of /u to "root".

chown root:staff /u
Likewise, but also change its group to "staff".
8 changes: 8 additions & 0 deletions files/usr/share/man/cp.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SYNOPSIS
cp SOURCE DEST

DESCRIPTION
Copy SOURCE to DEST.

OPTIONS
-h, --help shows command help.
14 changes: 11 additions & 3 deletions files/usr/share/man/echo.man
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
SYNOPSIS
echo [STRING]
echo [OPTIONS] [STRING]

DESCRIPTION
Displays a line of text.

echo displays a line of text.

The following options are available:

-n Do not output a newline.
-e Enable interpretation of backslash escapes.

If -e is in effect, the following sequences are recognized:

\n new line
5 changes: 5 additions & 0 deletions files/usr/share/man/false.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SYNOPSIS
false

DESCRIPTION
false sets the exit status to 1.
15 changes: 15 additions & 0 deletions files/usr/share/man/id.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SYNOPSIS
id [OPTIONS]

DESCRIPTION
Print user and group information for the current process.

The following options are available:

-g, --group
print only the effective group ID

-u, --user
print only the effective user ID

--help display a help message and exit
2 changes: 1 addition & 1 deletion files/usr/share/man/ipcs.man
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ SYNOPSIS
ipcs [options]

DESCRIPTION
Ipcs shows information on System V inter-process communication facilities.
Ipcs shows information on System V inter-process communication facilities.
8 changes: 5 additions & 3 deletions files/usr/share/man/ls.man
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ DESCRIPTION
inside the current folder.

OPTIONS
-h --help : shows command help.
-a --all : list all entries.
-l --long : show the entries as a detailed long list.
-h, --help shows command help.
-a, --all list all entries.
-l, --long show the entries as a detailed long list.
-i, --inode print the index number of each file
-1 list one file per line
17 changes: 17 additions & 0 deletions files/usr/share/man/man.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SYNOPSIS
man [PAGE]

DESCRIPTION
man is the system's manual pager. The page argument given to man is
normally the name of a program or utility.

Conventional section names include SYNOPSIS, CONFIGURATION, DESCRIPTION,
OPTIONS, EXIT STATUS and EXAMPLE.

The following conventions apply to the SYNOPSIS section and can be used as
a guide in other sections.

[-abc] any or all arguments within [ ] are optional.
-a|-b options delimited by | cannot be used together.
argument ... argument is repeatable.
[expression] ... entire expression within [ ] is repeatable.
2 changes: 1 addition & 1 deletion files/usr/share/man/mkdir.man
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ DESCRIPTION
Create the DIRECTORY, if it does not exist.

OPTIONS
--help : shows command help.
--help shows command help.
13 changes: 13 additions & 0 deletions files/usr/share/man/more.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SYNOPSIS
more [FILE]

DESCRIPTION
more is a filter for paging through text one screenful at a time.

OPTIONS
-h, --help shows command help.

KEY BINDINGS
q Exit from more
space Display next screen size
return Display next line
2 changes: 1 addition & 1 deletion files/usr/share/man/rmdir.man
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ DESCRIPTION
Remove the DIRECTORY, if it is empty.

OPTIONS
--help : shows command help.
-h, --help shows command help.
12 changes: 12 additions & 0 deletions files/usr/share/man/shell.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SYNOPSIS
shell [FILE]

DESCRIPTION
shell reads and executes commands from a file or from standard input.

INVOCATION
An interactive shell is one started without arguments, whose standard
input and error are both connected to terminals.

When shell is started as interactive shell it first reads and executes
commands from the file ~/.shellrc.
5 changes: 5 additions & 0 deletions files/usr/share/man/sleep.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SYNOPSIS
sleep NUMBER

DESCRIPTION
Pause for NUMBER seconds.
12 changes: 0 additions & 12 deletions files/usr/share/man/start.man

This file was deleted.

19 changes: 19 additions & 0 deletions files/usr/share/man/uname.man
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SYNOPSIS
uname [-a|-r|-i]

DESCRIPTION
Uname prints kernel and system information.

The following options are available:

-a, --all
Print kernel version and processor type

-r, --rev
Print only the kernel version

-i, --info
Print all info of system and kernel

-h, --help
Display a help message and exit
7 changes: 7 additions & 0 deletions iso/boot/grub/grub.cfg.runtests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set timeout=0
set default=0

menuentry "MentOS tests" {
multiboot /boot/bootloader.bin runtests
boot
}
11 changes: 11 additions & 0 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Add the library.
add_library(
libc
${CMAKE_SOURCE_DIR}/libc/src/err.c
${CMAKE_SOURCE_DIR}/libc/src/shadow.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/dup.c
${CMAKE_SOURCE_DIR}/libc/src/stdio.c
${CMAKE_SOURCE_DIR}/libc/src/ctype.c
${CMAKE_SOURCE_DIR}/libc/src/string.c
Expand All @@ -24,6 +27,7 @@ add_library(
${CMAKE_SOURCE_DIR}/libc/src/setenv.c
${CMAKE_SOURCE_DIR}/libc/src/assert.c
${CMAKE_SOURCE_DIR}/libc/src/abort.c
${CMAKE_SOURCE_DIR}/libc/src/crypt/sha256.c
${CMAKE_SOURCE_DIR}/libc/src/io/mm_io.c
${CMAKE_SOURCE_DIR}/libc/src/io/debug.c
${CMAKE_SOURCE_DIR}/libc/src/sys/ipc.c
Expand All @@ -32,6 +36,8 @@ add_library(
${CMAKE_SOURCE_DIR}/libc/src/sys/utsname.c
${CMAKE_SOURCE_DIR}/libc/src/sys/mman.c
${CMAKE_SOURCE_DIR}/libc/src/sys/ioctl.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/chmod.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/chown.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/creat.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/getppid.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/getpid.c
Expand Down Expand Up @@ -75,3 +81,8 @@ target_include_directories(libc PUBLIC inc)

# Remove the 'lib' prefix.
set_target_properties(libc PROPERTIES PREFIX "")

# If the emulator is set to output on a log file, tell that to the C code.
if(${EMULATOR_OUTPUT_TYPE} STREQUAL OUTPUT_LOG)
target_compile_definitions(libc PUBLIC EMULATOR_OUTPUT_LOG)
endif()
Loading

0 comments on commit 0db5c73

Please sign in to comment.