mirror of
https://github.com/tailix/libkernaux.git
synced 2024-11-27 11:14:42 -05:00
Merge branch 'master' into paging
This commit is contained in:
commit
3e81c660e8
61 changed files with 1015 additions and 822 deletions
|
@ -12,7 +12,7 @@ main_freebsd_task:
|
||||||
- pip install --user Jinja2 PyYAML
|
- pip install --user Jinja2 PyYAML
|
||||||
main_build_script:
|
main_build_script:
|
||||||
- ./autogen.sh
|
- ./autogen.sh
|
||||||
- ./configure --enable-debug --enable-checks-all CFLAGS='-O3'
|
- ./configure --enable-debug --enable-fixtures --enable-checks-all CFLAGS='-O3'
|
||||||
- make
|
- make
|
||||||
- sudo make install
|
- sudo make install
|
||||||
main_test_script:
|
main_test_script:
|
||||||
|
@ -46,7 +46,7 @@ ruby_freebsd_task:
|
||||||
CPATH: '/usr/local/include'
|
CPATH: '/usr/local/include'
|
||||||
LIBRARY_PATH: '/usr/local/lib'
|
LIBRARY_PATH: '/usr/local/lib'
|
||||||
dependencies_script:
|
dependencies_script:
|
||||||
- pkg install --yes autoconf automake git libtool wget
|
- pkg install --yes autoconf automake cppcheck git libtool wget
|
||||||
dependencies_ruby_script:
|
dependencies_ruby_script:
|
||||||
- wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.3.tar.gz
|
- wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.3.tar.gz
|
||||||
- tar -xzf ruby-3.0.3.tar.gz
|
- tar -xzf ruby-3.0.3.tar.gz
|
||||||
|
|
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
@ -34,7 +34,7 @@ jobs:
|
||||||
- name: autogen
|
- name: autogen
|
||||||
run: ./autogen.sh
|
run: ./autogen.sh
|
||||||
- name: configure
|
- name: configure
|
||||||
run: ./configure ${{matrix.debug}} --enable-checks --enable-checks-pthreads --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}'
|
run: ./configure ${{matrix.debug}} --enable-fixtures --enable-checks --enable-checks-pthreads --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}'
|
||||||
- name: make
|
- name: make
|
||||||
run: make
|
run: make
|
||||||
- name: check
|
- name: check
|
||||||
|
|
3
.github/workflows/mruby.yml
vendored
3
.github/workflows/mruby.yml
vendored
|
@ -46,6 +46,3 @@ jobs:
|
||||||
- working-directory: bindings/mruby
|
- working-directory: bindings/mruby
|
||||||
name: lint
|
name: lint
|
||||||
run: rake
|
run: rake
|
||||||
- working-directory: bindings/mruby
|
|
||||||
name: cppcheck
|
|
||||||
run: cppcheck --quiet --error-exitcode=1 --std=c99 --enable=warning,style,performance,portability .
|
|
||||||
|
|
3
.github/workflows/ruby.yml
vendored
3
.github/workflows/ruby.yml
vendored
|
@ -44,6 +44,3 @@ jobs:
|
||||||
- working-directory: bindings/ruby
|
- working-directory: bindings/ruby
|
||||||
name: test & lint
|
name: test & lint
|
||||||
run: SKIP_COVERAGE='${{matrix.packages.skip_coverage}}' rake
|
run: SKIP_COVERAGE='${{matrix.packages.skip_coverage}}' rake
|
||||||
- working-directory: bindings/ruby
|
|
||||||
name: cppcheck
|
|
||||||
run: cppcheck --quiet --error-exitcode=1 --std=c99 --enable=warning,style,performance,portability .
|
|
||||||
|
|
66
.gitignore
vendored
66
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
||||||
|
/build/*
|
||||||
|
!/build/.keep
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# Common generated files #
|
# Common generated files #
|
||||||
##########################
|
##########################
|
||||||
|
@ -38,10 +41,9 @@
|
||||||
/m4/*
|
/m4/*
|
||||||
!/m4/.keep
|
!/m4/.keep
|
||||||
|
|
||||||
# Custom
|
|
||||||
|
|
||||||
/Makefile.in
|
/Makefile.in
|
||||||
/examples/Makefile.in
|
/examples/Makefile.in
|
||||||
|
/fixtures/Makefile.in
|
||||||
/include/Makefile.in
|
/include/Makefile.in
|
||||||
/libc/Makefile.in
|
/libc/Makefile.in
|
||||||
/libc/include/Makefile.in
|
/libc/include/Makefile.in
|
||||||
|
@ -57,7 +59,6 @@
|
||||||
/libtool
|
/libtool
|
||||||
/stamp-h1
|
/stamp-h1
|
||||||
|
|
||||||
# Temporary
|
|
||||||
/confcache
|
/confcache
|
||||||
/confdefs.h
|
/confdefs.h
|
||||||
/confinc.mk
|
/confinc.mk
|
||||||
|
@ -73,67 +74,10 @@
|
||||||
/tests/test_*.log
|
/tests/test_*.log
|
||||||
/tests/test_*.trs
|
/tests/test_*.trs
|
||||||
|
|
||||||
# Custom
|
|
||||||
|
|
||||||
/Makefile
|
/Makefile
|
||||||
/examples/Makefile
|
/examples/Makefile
|
||||||
|
/fixtures/Makefile
|
||||||
/include/Makefile
|
/include/Makefile
|
||||||
/libc/Makefile
|
/libc/Makefile
|
||||||
/libc/include/Makefile
|
/libc/include/Makefile
|
||||||
/tests/Makefile
|
/tests/Makefile
|
||||||
|
|
||||||
/include/kernaux/version.h
|
|
||||||
|
|
||||||
/examples/assert
|
|
||||||
/examples/cmdline
|
|
||||||
/examples/generic_display
|
|
||||||
/examples/generic_malloc
|
|
||||||
/examples/generic_mutex
|
|
||||||
/examples/macro_bits
|
|
||||||
/examples/macro_cast
|
|
||||||
/examples/macro_container_of
|
|
||||||
/examples/macro_packing
|
|
||||||
/examples/macro_static_test
|
|
||||||
/examples/memmap
|
|
||||||
/examples/multiboot2_header_macro
|
|
||||||
/examples/ntoa
|
|
||||||
/examples/panic
|
|
||||||
/examples/pfa
|
|
||||||
/examples/printf_file
|
|
||||||
/examples/printf_file_va
|
|
||||||
/examples/printf_fmt
|
|
||||||
/examples/printf_str
|
|
||||||
/examples/printf_str_va
|
|
||||||
/examples/units_human
|
|
||||||
|
|
||||||
/tests/multiboot2_header_print0
|
|
||||||
/tests/multiboot2_header_print1
|
|
||||||
/tests/multiboot2_header_print2
|
|
||||||
/tests/multiboot2_info_print0
|
|
||||||
/tests/multiboot2_info_print1
|
|
||||||
/tests/multiboot2_info_print2
|
|
||||||
/tests/test_arch_i386
|
|
||||||
/tests/test_cmdline
|
|
||||||
/tests/test_cmdline_gen
|
|
||||||
/tests/test_cmdline_gen.c
|
|
||||||
/tests/test_elf
|
|
||||||
/tests/test_free_list
|
|
||||||
/tests/test_mbr
|
|
||||||
/tests/test_memmap
|
|
||||||
/tests/test_multiboot2_common_packing
|
|
||||||
/tests/test_multiboot2_header_helpers
|
|
||||||
/tests/test_multiboot2_header_print
|
|
||||||
/tests/test_multiboot2_header_validation
|
|
||||||
/tests/test_multiboot2_info_helpers
|
|
||||||
/tests/test_multiboot2_info_print
|
|
||||||
/tests/test_multiboot2_info_validation
|
|
||||||
/tests/test_ntoa
|
|
||||||
/tests/test_ntoa_assert
|
|
||||||
/tests/test_pfa
|
|
||||||
/tests/test_pfa_assert
|
|
||||||
/tests/test_printf
|
|
||||||
/tests/test_printf_fmt_gen
|
|
||||||
/tests/test_printf_fmt_gen.c
|
|
||||||
/tests/test_printf_gen
|
|
||||||
/tests/test_printf_gen.c
|
|
||||||
/tests/test_units_human
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ tasks:
|
||||||
- build: |
|
- build: |
|
||||||
cd libkernaux
|
cd libkernaux
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
./configure --enable-debug --enable-checks-all CFLAGS='-O3'
|
./configure --enable-debug --enable-fixtures --enable-checks-all CFLAGS='-O3'
|
||||||
make
|
make
|
||||||
doas make install
|
doas make install
|
||||||
- test: |
|
- test: |
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
2022-12-17 Alex Kotov <kotovalexarian@gmail.com>
|
2022-12-17 Alex Kotov <kotovalexarian@gmail.com>
|
||||||
|
|
||||||
|
* configure.ac: Feature "--(enable|disable)-fixtures" has been added
|
||||||
* src/multiboot2/*_print.c: Print some values in hex
|
* src/multiboot2/*_print.c: Print some values in hex
|
||||||
|
|
||||||
2022-12-16 Alex Kotov <kotovalexarian@gmail.com>
|
2022-12-16 Alex Kotov <kotovalexarian@gmail.com>
|
||||||
|
|
||||||
* configure.ac: Feature "--with[out]-multiboot2" has been added
|
* configure.ac: Package "--with[out]-multiboot2" has been added
|
||||||
* include/kernaux/multiboot2.h: Has been made stable
|
* include/kernaux/multiboot2.h: Has been made stable
|
||||||
|
|
||||||
2022-12-14 Alex Kotov <kotovalexarian@gmail.com>
|
2022-12-14 Alex Kotov <kotovalexarian@gmail.com>
|
||||||
|
|
|
@ -13,6 +13,10 @@ endif
|
||||||
|
|
||||||
SUBDIRS += .
|
SUBDIRS += .
|
||||||
|
|
||||||
|
if ENABLE_FIXTURES
|
||||||
|
SUBDIRS += fixtures
|
||||||
|
endif
|
||||||
|
|
||||||
if ENABLE_CHECKS
|
if ENABLE_CHECKS
|
||||||
SUBDIRS += examples tests
|
SUBDIRS += examples tests
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -142,6 +142,7 @@ stable options.
|
||||||
* `--enable-checks-pthreads` - enable tests that require pthreads
|
* `--enable-checks-pthreads` - enable tests that require pthreads
|
||||||
* `--enable-checks-python` - enable tests that require Python 3 with YAML and
|
* `--enable-checks-python` - enable tests that require Python 3 with YAML and
|
||||||
Jinja2
|
Jinja2
|
||||||
|
* `--enable-fixtures` - enable fixtures for tests and bindings
|
||||||
|
|
||||||
#### Packages
|
#### Packages
|
||||||
|
|
||||||
|
@ -195,12 +196,18 @@ environment.
|
||||||
|
|
||||||
```
|
```
|
||||||
./autogen.sh # if present
|
./autogen.sh # if present
|
||||||
./configure --enable-checks # or --enable-checks-all, but see prerequisites
|
./configure --enable-fixtures --enable-checks # or --enable-checks-all, but see prerequisites
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
You can test with `make check`.
|
You can test with `make check`.
|
||||||
|
|
||||||
|
#### See also
|
||||||
|
|
||||||
|
* [GitHub Actions](/.github/) for **GNU/Linux** build environment
|
||||||
|
* [Cirrus CI](/.cirrus.yml) for **FreeBSD** build environment
|
||||||
|
* [sourcehut CI](/.openbsd.yml) for **OpenBSD** build environment
|
||||||
|
|
||||||
### Cross
|
### Cross
|
||||||
|
|
||||||
Create configuration script with `./autogen.sh` (if present).
|
Create configuration script with `./autogen.sh` (if present).
|
||||||
|
|
|
@ -4,7 +4,7 @@ desc 'Run default checks'
|
||||||
task default: :lint
|
task default: :lint
|
||||||
|
|
||||||
desc 'Run code analysis tools'
|
desc 'Run code analysis tools'
|
||||||
task lint: :rubocop
|
task lint: %i[rubocop cppcheck]
|
||||||
|
|
||||||
desc 'Fix code style (rubocop --auto-correct)'
|
desc 'Fix code style (rubocop --auto-correct)'
|
||||||
task fix: 'rubocop:auto_correct'
|
task fix: 'rubocop:auto_correct'
|
||||||
|
@ -15,3 +15,15 @@ begin
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Run cppcheck'
|
||||||
|
task :cppcheck do
|
||||||
|
sh(
|
||||||
|
'cppcheck',
|
||||||
|
'--quiet',
|
||||||
|
'--error-exitcode=1',
|
||||||
|
'--std=c99',
|
||||||
|
'--enable=warning,style,performance,portability',
|
||||||
|
__dir__,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <mruby/presym.h>
|
#include <mruby/presym.h>
|
||||||
#include <mruby/string.h>
|
#include <mruby/string.h>
|
||||||
#include <mruby/variable.h>
|
#include <mruby/variable.h>
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <mruby/array.h>
|
#include <mruby/array.h>
|
||||||
#include <mruby/presym.h>
|
#include <mruby/presym.h>
|
||||||
#include <mruby/string.h>
|
#include <mruby/string.h>
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
#include <kernaux.h>
|
#include <kernaux.h>
|
||||||
#include <mruby.h>
|
#include <mruby.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
void current_mrb_start(mrb_state *mrb);
|
void current_mrb_start(mrb_state *mrb);
|
||||||
void current_mrb_finish(mrb_state *mrb);
|
void current_mrb_finish(mrb_state *mrb);
|
||||||
mrb_state *current_mrb_get();
|
mrb_state *current_mrb_get();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <mruby/numeric.h>
|
#include <mruby/numeric.h>
|
||||||
#include <mruby/presym.h>
|
#include <mruby/presym.h>
|
||||||
#include <mruby/string.h>
|
#include <mruby/string.h>
|
||||||
|
|
|
@ -29,8 +29,7 @@ void init_printf(mrb_state *const mrb)
|
||||||
|
|
||||||
mrb_value rb_KernAux_sprintf(mrb_state *const mrb, mrb_value self)
|
mrb_value rb_KernAux_sprintf(mrb_state *const mrb, mrb_value self)
|
||||||
{
|
{
|
||||||
// FIXME: const
|
const char *format;
|
||||||
char *format;
|
|
||||||
mrb_value *args;
|
mrb_value *args;
|
||||||
mrb_int argc;
|
mrb_int argc;
|
||||||
mrb_get_args(mrb, "z*", &format, &args, &argc);
|
mrb_get_args(mrb, "z*", &format, &args, &argc);
|
||||||
|
@ -45,12 +44,9 @@ mrb_value rb_KernAux_sprintf(mrb_state *const mrb, mrb_value self)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: unnecessary
|
|
||||||
const char *const old_format = format;
|
|
||||||
++format;
|
++format;
|
||||||
struct KernAux_PrintfFmt_Spec spec =
|
struct KernAux_PrintfFmt_Spec spec =
|
||||||
// FIXME: no type cast
|
KernAux_PrintfFmt_Spec_create_out(&format);
|
||||||
KernAux_PrintfFmt_Spec_create_out((const char**)&format);
|
|
||||||
|
|
||||||
if (spec.set_width) {
|
if (spec.set_width) {
|
||||||
TAKE_ARG;
|
TAKE_ARG;
|
||||||
|
@ -87,14 +83,16 @@ mrb_value rb_KernAux_sprintf(mrb_state *const mrb, mrb_value self)
|
||||||
DynArg_use_str(&dynarg, RSTRING_CSTR(mrb, arg_rb));
|
DynArg_use_str(&dynarg, RSTRING_CSTR(mrb, arg_rb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1 additional byte for the '%' character.
|
||||||
|
// 1 additional byte for the terminating '\0' character.
|
||||||
|
char old_format[2 + spec.format_limit - spec.format_start];
|
||||||
|
memset(old_format, '\0', sizeof(old_format));
|
||||||
|
old_format[0] = '%';
|
||||||
|
strncpy(&old_format[1], spec.format_start, sizeof(old_format) - 2);
|
||||||
|
|
||||||
char buffer[BUFFER_SIZE];
|
char buffer[BUFFER_SIZE];
|
||||||
int slen;
|
int slen;
|
||||||
|
|
||||||
// FIXME: it's a hack
|
|
||||||
// TODO: convert printf format spec to string
|
|
||||||
const char tmp = *format;
|
|
||||||
*format = '\0';
|
|
||||||
|
|
||||||
if (spec.set_width) {
|
if (spec.set_width) {
|
||||||
if (spec.set_precision) {
|
if (spec.set_precision) {
|
||||||
if (dynarg.use_dbl) {
|
if (dynarg.use_dbl) {
|
||||||
|
@ -133,7 +131,6 @@ mrb_value rb_KernAux_sprintf(mrb_state *const mrb, mrb_value self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*format = tmp;
|
|
||||||
mrb_str_cat(mrb, result, buffer, slen);
|
mrb_str_cat(mrb, result, buffer, slen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@ if KernAux::Version.with_cmdline?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
assert 'usign common tests' do
|
assert 'usign fixtures' do
|
||||||
cmdline_yml = File.expand_path('../../../../common/cmdline.yml', __FILE__)
|
cmdline_yml = File.expand_path('../../../../fixtures/cmdline.yml', __FILE__)
|
||||||
|
|
||||||
YAML.load(File.read(cmdline_yml)).each do |test|
|
YAML.load(File.read(cmdline_yml)).each do |test|
|
||||||
escape_str = lambda do |str|
|
escape_str = lambda do |str|
|
||||||
|
|
|
@ -65,12 +65,12 @@ if KernAux::Version.with_printf?
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
['', 'using regular tests'],
|
['', 'using regular fixtures'],
|
||||||
['_orig', 'using original tests'],
|
['_orig', 'using original fixtures'],
|
||||||
].each do |(suffix, description)|
|
].each do |(suffix, description)|
|
||||||
assert description do
|
assert description do
|
||||||
printf_yml =
|
printf_yml =
|
||||||
File.expand_path("../../../../common/printf#{suffix}.yml", __FILE__)
|
File.expand_path("../../../../fixtures/printf#{suffix}.yml", __FILE__)
|
||||||
|
|
||||||
YAML.load(File.read(printf_yml)).each do |test|
|
YAML.load(File.read(printf_yml)).each do |test|
|
||||||
expected = test['result']
|
expected = test['result']
|
||||||
|
|
|
@ -20,13 +20,13 @@ CLEAN << 'doc'
|
||||||
CLEAN << 'spec/examples.txt'
|
CLEAN << 'spec/examples.txt'
|
||||||
|
|
||||||
desc 'Run default checks'
|
desc 'Run default checks'
|
||||||
task default: %i[test lint yard:cov]
|
task default: %i[test lint]
|
||||||
|
|
||||||
desc 'Run tests'
|
desc 'Run tests'
|
||||||
task test: :spec
|
task test: :spec
|
||||||
|
|
||||||
desc 'Run code analysis tools'
|
desc 'Run code analysis tools'
|
||||||
task lint: :rubocop
|
task lint: %i[rubocop cppcheck yard:cov]
|
||||||
|
|
||||||
desc 'Fix code style (rubocop --auto-correct)'
|
desc 'Fix code style (rubocop --auto-correct)'
|
||||||
task fix: 'rubocop:auto_correct'
|
task fix: 'rubocop:auto_correct'
|
||||||
|
@ -66,6 +66,18 @@ task :console do
|
||||||
sh 'bundle', 'exec', File.expand_path(File.join('bin', 'console'), __dir__)
|
sh 'bundle', 'exec', File.expand_path(File.join('bin', 'console'), __dir__)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc 'Run cppcheck'
|
||||||
|
task :cppcheck do
|
||||||
|
sh(
|
||||||
|
'cppcheck',
|
||||||
|
'--quiet',
|
||||||
|
'--error-exitcode=1',
|
||||||
|
'--std=c99',
|
||||||
|
'--enable=warning,style,performance,portability',
|
||||||
|
__dir__,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
namespace :yard do
|
namespace :yard do
|
||||||
desc 'Measure documentation coverage'
|
desc 'Measure documentation coverage'
|
||||||
task :cov do
|
task :cov do
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
#include <kernaux.h>
|
#include <kernaux.h>
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
extern ID rb_intern_call;
|
extern ID rb_intern_call;
|
||||||
extern ID rb_intern_freeze;
|
extern ID rb_intern_freeze;
|
||||||
extern ID rb_intern_LESS;
|
extern ID rb_intern_LESS;
|
||||||
|
|
|
@ -31,8 +31,7 @@ VALUE rb_KernAux_sprintf(const int argc, VALUE *const argv, VALUE self)
|
||||||
{
|
{
|
||||||
if (argc == 0) rb_raise(rb_eArgError, "too few arguments");
|
if (argc == 0) rb_raise(rb_eArgError, "too few arguments");
|
||||||
|
|
||||||
// FIXME: const
|
const char *format = StringValueCStr(argv[0]);
|
||||||
char *format = StringValueCStr(argv[0]);
|
|
||||||
int arg_index = 1;
|
int arg_index = 1;
|
||||||
VALUE result = rb_str_new_literal("");
|
VALUE result = rb_str_new_literal("");
|
||||||
|
|
||||||
|
@ -43,12 +42,9 @@ VALUE rb_KernAux_sprintf(const int argc, VALUE *const argv, VALUE self)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: unnecessary
|
|
||||||
const char *const old_format = format;
|
|
||||||
++format;
|
++format;
|
||||||
struct KernAux_PrintfFmt_Spec spec =
|
struct KernAux_PrintfFmt_Spec spec =
|
||||||
// FIXME: no type cast
|
KernAux_PrintfFmt_Spec_create_out(&format);
|
||||||
KernAux_PrintfFmt_Spec_create_out((const char**)&format);
|
|
||||||
|
|
||||||
if (spec.set_width) {
|
if (spec.set_width) {
|
||||||
TAKE_ARG;
|
TAKE_ARG;
|
||||||
|
@ -82,14 +78,16 @@ VALUE rb_KernAux_sprintf(const int argc, VALUE *const argv, VALUE self)
|
||||||
DynArg_use_str(&dynarg, StringValueCStr(arg_rb));
|
DynArg_use_str(&dynarg, StringValueCStr(arg_rb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1 additional byte for the '%' character.
|
||||||
|
// 1 additional byte for the terminating '\0' character.
|
||||||
|
char old_format[2 + spec.format_limit - spec.format_start];
|
||||||
|
memset(old_format, '\0', sizeof(old_format));
|
||||||
|
old_format[0] = '%';
|
||||||
|
strncpy(&old_format[1], spec.format_start, sizeof(old_format) - 2);
|
||||||
|
|
||||||
char buffer[BUFFER_SIZE];
|
char buffer[BUFFER_SIZE];
|
||||||
int slen;
|
int slen;
|
||||||
|
|
||||||
// FIXME: it's a hack
|
|
||||||
// TODO: convert printf format spec to string
|
|
||||||
const char tmp = *format;
|
|
||||||
*format = '\0';
|
|
||||||
|
|
||||||
if (spec.set_width) {
|
if (spec.set_width) {
|
||||||
if (spec.set_precision) {
|
if (spec.set_precision) {
|
||||||
if (dynarg.use_dbl) {
|
if (dynarg.use_dbl) {
|
||||||
|
@ -128,7 +126,6 @@ VALUE rb_KernAux_sprintf(const int argc, VALUE *const argv, VALUE self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*format = tmp;
|
|
||||||
rb_str_cat(result, buffer, slen);
|
rb_str_cat(result, buffer, slen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,9 @@ KernAux::Version.with_cmdline? and RSpec.describe KernAux, '.cmdline' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'using common tests' do
|
context 'using fixtures' do
|
||||||
cmdline_yml = File.expand_path('../../../../../common/cmdline.yml', __dir__)
|
cmdline_yml =
|
||||||
|
File.expand_path('../../../../../fixtures/cmdline.yml', __dir__)
|
||||||
|
|
||||||
YAML.safe_load_file(cmdline_yml).each do |test|
|
YAML.safe_load_file(cmdline_yml).each do |test|
|
||||||
escape_str = lambda do |str|
|
escape_str = lambda do |str|
|
||||||
|
|
|
@ -39,12 +39,12 @@ KernAux::Version.with_printf? and RSpec.describe KernAux, '.sprintf' do
|
||||||
end
|
end
|
||||||
|
|
||||||
[
|
[
|
||||||
['', 'using regular tests'],
|
['', 'using regular fixtures'],
|
||||||
['_orig', 'using original tests'],
|
['_orig', 'using original fixtures'],
|
||||||
].each do |(suffix, description)|
|
].each do |(suffix, description)|
|
||||||
context description do
|
context description do
|
||||||
printf_yml = File.expand_path(
|
printf_yml = File.expand_path(
|
||||||
"../../../../../common/printf#{suffix}.yml",
|
"../../../../../fixtures/printf#{suffix}.yml",
|
||||||
__dir__,
|
__dir__,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
0
build/.keep
Normal file
0
build/.keep
Normal file
10
configure.ac
10
configure.ac
|
@ -26,11 +26,15 @@ AC_CONFIG_SRCDIR([src/assert.c])
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
examples/Makefile
|
examples/Makefile
|
||||||
|
fixtures/Makefile
|
||||||
|
fixtures/multiboot2_bin_examples_gen.c
|
||||||
include/Makefile
|
include/Makefile
|
||||||
libc/Makefile
|
libc/Makefile
|
||||||
libc/include/Makefile
|
libc/include/Makefile
|
||||||
include/kernaux/version.h
|
include/kernaux/version.h
|
||||||
tests/Makefile
|
tests/Makefile
|
||||||
|
tests/test_multiboot2_header_print.c
|
||||||
|
tests/test_multiboot2_info_print.c
|
||||||
])
|
])
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.16 subdir-objects])
|
AM_INIT_AUTOMAKE([1.16 subdir-objects])
|
||||||
|
@ -49,6 +53,7 @@ AC_ARG_ENABLE([float], AS_HELP_STRING([--disable-float], [dis
|
||||||
AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror]))
|
AC_ARG_ENABLE([werror], AS_HELP_STRING([--disable-werror], [disable -Werror]))
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
|
AC_ARG_ENABLE([fixtures], AS_HELP_STRING([--enable-fixtures], [enable fixtures for tests and bindings]))
|
||||||
AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [build for freestanding environment]))
|
AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [build for freestanding environment]))
|
||||||
AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc]))
|
AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc]))
|
||||||
AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests and examples]))
|
AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests and examples]))
|
||||||
|
@ -134,6 +139,7 @@ AS_IF([test "$enable_float" = no ], [enable_float=no], [ena
|
||||||
AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes])
|
AS_IF([test "$enable_werror" = no ], [enable_werror=no], [enable_werror=yes])
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
|
AS_IF([test "$enable_fixtures" = yes], [enable_fixtures=yes], [enable_fixtures=no])
|
||||||
AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [enable_freestanding=no])
|
AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [enable_freestanding=no])
|
||||||
AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no])
|
AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no])
|
||||||
AS_IF([test "$enable_checks" = yes], [enable_checks=yes], [enable_checks=no])
|
AS_IF([test "$enable_checks" = yes], [enable_checks=yes], [enable_checks=no])
|
||||||
|
@ -171,7 +177,9 @@ AS_IF([test "$with_libc" = yes], [with_libc=yes], [wit
|
||||||
#############
|
#############
|
||||||
|
|
||||||
AS_IF([test "$enable_checks" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests]))
|
AS_IF([test "$enable_checks" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding tests]))
|
||||||
|
AS_IF([test "$enable_fixtures" = yes -a "$enable_freestanding" = yes], AC_MSG_ERROR([can not build freestanding fixtures]))
|
||||||
AS_IF([test "$enable_checks" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests]))
|
AS_IF([test "$enable_checks" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with tests]))
|
||||||
|
AS_IF([test "$enable_fixtures" = yes -a "$with_libc" = yes], AC_MSG_ERROR([can not use package `libc' with fixtures]))
|
||||||
|
|
||||||
AS_IF([test "$with_printf" = yes -a "$with_ntoa" = no], AC_MSG_ERROR([package `printf' requires package `ntoa']))
|
AS_IF([test "$with_printf" = yes -a "$with_ntoa" = no], AC_MSG_ERROR([package `printf' requires package `ntoa']))
|
||||||
AS_IF([test "$with_printf" = yes -a "$with_printf_fmt" = no], AC_MSG_ERROR([package `printf' requires package `printf-fmt']))
|
AS_IF([test "$with_printf" = yes -a "$with_printf_fmt" = no], AC_MSG_ERROR([package `printf' requires package `printf-fmt']))
|
||||||
|
@ -197,6 +205,7 @@ AM_CONDITIONAL([ENABLE_FLOAT], [test "$enable_float" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])
|
AM_CONDITIONAL([ENABLE_WERROR], [test "$enable_werror" = yes])
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
|
AM_CONDITIONAL([ENABLE_FIXTURES], [test "$enable_fixtures" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes])
|
AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes])
|
AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes])
|
||||||
AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes])
|
AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes])
|
||||||
|
@ -249,6 +258,7 @@ AS_IF([test "$enable_werror" = yes], [AC_DEFINE([ENABLE_WERROR],
|
||||||
|
|
||||||
dnl Features (disabled by default)
|
dnl Features (disabled by default)
|
||||||
AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])])
|
AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])])
|
||||||
|
AS_IF([test "$enable_fixtures" = yes], [AC_DEFINE([ENABLE_FIXTURES], [1], [enabled fixtures for tests and bindings])])
|
||||||
AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])])
|
AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])])
|
||||||
AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests and examples])])
|
AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests and examples])])
|
||||||
AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])])
|
AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])])
|
||||||
|
|
21
examples/.gitignore
vendored
Normal file
21
examples/.gitignore
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/assert
|
||||||
|
/cmdline
|
||||||
|
/generic_display
|
||||||
|
/generic_malloc
|
||||||
|
/generic_mutex
|
||||||
|
/macro_bits
|
||||||
|
/macro_cast
|
||||||
|
/macro_container_of
|
||||||
|
/macro_packing
|
||||||
|
/macro_static_test
|
||||||
|
/memmap
|
||||||
|
/multiboot2_header_macro
|
||||||
|
/ntoa
|
||||||
|
/panic
|
||||||
|
/pfa
|
||||||
|
/printf_file
|
||||||
|
/printf_file_va
|
||||||
|
/printf_fmt
|
||||||
|
/printf_str
|
||||||
|
/printf_str_va
|
||||||
|
/units_human
|
8
fixtures/.gitignore
vendored
Normal file
8
fixtures/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/multiboot2_bin_examples_gen
|
||||||
|
/multiboot2_bin_examples_gen.c
|
||||||
|
/multiboot2_header_example0.bin
|
||||||
|
/multiboot2_header_example1.bin
|
||||||
|
/multiboot2_header_example2.bin
|
||||||
|
/multiboot2_info_example0.bin
|
||||||
|
/multiboot2_info_example1.bin
|
||||||
|
/multiboot2_info_example2.bin
|
61
fixtures/Makefile.am
Normal file
61
fixtures/Makefile.am
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
include $(top_srcdir)/make/shared.am
|
||||||
|
|
||||||
|
noinst_PROGRAMS =
|
||||||
|
nodist_noinst_DATA =
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
multiboot2_header_example0.txt \
|
||||||
|
multiboot2_header_example1.txt \
|
||||||
|
multiboot2_header_example2.txt \
|
||||||
|
multiboot2_info_example0.txt \
|
||||||
|
multiboot2_info_example1.txt \
|
||||||
|
multiboot2_info_example2.txt
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
# multiboot2_(header|info)_example*.bin #
|
||||||
|
#########################################
|
||||||
|
|
||||||
|
if WITH_MULTIBOOT2
|
||||||
|
nodist_noinst_DATA += \
|
||||||
|
multiboot2_header_example0.bin \
|
||||||
|
multiboot2_header_example1.bin \
|
||||||
|
multiboot2_header_example2.bin \
|
||||||
|
multiboot2_info_example0.bin \
|
||||||
|
multiboot2_info_example1.bin \
|
||||||
|
multiboot2_info_example2.bin
|
||||||
|
endif
|
||||||
|
|
||||||
|
multiboot2_header_example0.bin: multiboot2_bin_examples_gen
|
||||||
|
./multiboot2_bin_examples_gen header 0
|
||||||
|
|
||||||
|
multiboot2_header_example1.bin: multiboot2_bin_examples_gen
|
||||||
|
./multiboot2_bin_examples_gen header 1
|
||||||
|
|
||||||
|
multiboot2_header_example2.bin: multiboot2_bin_examples_gen
|
||||||
|
./multiboot2_bin_examples_gen header 2
|
||||||
|
|
||||||
|
multiboot2_info_example0.bin: multiboot2_bin_examples_gen
|
||||||
|
./multiboot2_bin_examples_gen info 0
|
||||||
|
|
||||||
|
multiboot2_info_example1.bin: multiboot2_bin_examples_gen
|
||||||
|
./multiboot2_bin_examples_gen info 1
|
||||||
|
|
||||||
|
multiboot2_info_example2.bin: multiboot2_bin_examples_gen
|
||||||
|
./multiboot2_bin_examples_gen info 2
|
||||||
|
|
||||||
|
###############################
|
||||||
|
# multiboot2_bin_examples_gen #
|
||||||
|
###############################
|
||||||
|
|
||||||
|
if WITH_MULTIBOOT2
|
||||||
|
noinst_PROGRAMS += multiboot2_bin_examples_gen
|
||||||
|
multiboot2_bin_examples_gen_LDADD = $(top_builddir)/libkernaux.la
|
||||||
|
nodist_multiboot2_bin_examples_gen_SOURCES = multiboot2_bin_examples_gen.c
|
||||||
|
multiboot2_bin_examples_gen_SOURCES = \
|
||||||
|
multiboot2_header_example0.h \
|
||||||
|
multiboot2_header_example1.h \
|
||||||
|
multiboot2_header_example2.h \
|
||||||
|
multiboot2_info_example0.h \
|
||||||
|
multiboot2_info_example1.h \
|
||||||
|
multiboot2_info_example2.h
|
||||||
|
endif
|
84
fixtures/multiboot2_bin_examples_gen.c.in
Normal file
84
fixtures/multiboot2_bin_examples_gen.c.in
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <kernaux/assert.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "multiboot2_header_example0.h"
|
||||||
|
#include "multiboot2_header_example1.h"
|
||||||
|
#include "multiboot2_header_example2.h"
|
||||||
|
#include "multiboot2_info_example0.h"
|
||||||
|
#include "multiboot2_info_example1.h"
|
||||||
|
#include "multiboot2_info_example2.h"
|
||||||
|
|
||||||
|
static void assert_cb(
|
||||||
|
const char *const file,
|
||||||
|
const int line,
|
||||||
|
const char *const msg
|
||||||
|
) {
|
||||||
|
fprintf(stderr, "%s:%d:%s\n", file, line, msg);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EXAMPLE(type, number) do { \
|
||||||
|
static const char *const filename = \
|
||||||
|
"@abs_top_builddir@/fixtures/multiboot2_"#type"_example"#number".bin"; \
|
||||||
|
FILE *const file = fopen(filename, "w"); \
|
||||||
|
assert(file); \
|
||||||
|
assert( \
|
||||||
|
fwrite( \
|
||||||
|
&multiboot2_##type##_example##number, \
|
||||||
|
1, \
|
||||||
|
sizeof(multiboot2_##type##_example##number), \
|
||||||
|
file \
|
||||||
|
) == sizeof(multiboot2_##type##_example##number) \
|
||||||
|
); \
|
||||||
|
assert(fclose(file) == 0); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
int main(const int argc, const char *const *const argv)
|
||||||
|
{
|
||||||
|
kernaux_assert_cb = assert_cb;
|
||||||
|
|
||||||
|
assert(argc == 3);
|
||||||
|
|
||||||
|
const char *const type = argv[1];
|
||||||
|
const char *const number = argv[2];
|
||||||
|
|
||||||
|
if (strcmp(type, "header") == 0) {
|
||||||
|
if (strcmp(number, "0") == 0) {
|
||||||
|
EXAMPLE(header, 0);
|
||||||
|
}
|
||||||
|
else if (strcmp(number, "1") == 0) {
|
||||||
|
EXAMPLE(header, 1);
|
||||||
|
}
|
||||||
|
else if (strcmp(number, "2") == 0) {
|
||||||
|
EXAMPLE(header, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
} else if (strcmp(type, "info") == 0) {
|
||||||
|
if (strcmp(number, "0") == 0) {
|
||||||
|
EXAMPLE(info, 0);
|
||||||
|
}
|
||||||
|
else if (strcmp(number, "1") == 0) {
|
||||||
|
EXAMPLE(info, 1);
|
||||||
|
}
|
||||||
|
else if (strcmp(number, "2") == 0) {
|
||||||
|
EXAMPLE(info, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
11
fixtures/multiboot2_header_example0.txt
Normal file
11
fixtures/multiboot2_header_example0.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Multiboot 2 header {
|
||||||
|
u32 magic: 0xe85250d6
|
||||||
|
u32 arch: 0 (i386)
|
||||||
|
u32 size: 24
|
||||||
|
u32 checksum: 0x17adaf12
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 0 (none)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 8
|
||||||
|
}
|
52
fixtures/multiboot2_header_example1.txt
Normal file
52
fixtures/multiboot2_header_example1.txt
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
Multiboot 2 header {
|
||||||
|
u32 magic: 0xe85250d6
|
||||||
|
u32 arch: 4 (MIPS32)
|
||||||
|
u32 size: 104
|
||||||
|
u32 checksum: 0x17adaebe
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 4 (flags)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 console_flags: 0x0 ()
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 4 (flags)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 console_flags: 0x1 (
|
||||||
|
REQUIRE_CONSOLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 4 (flags)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 console_flags: 0x2 (
|
||||||
|
EGA_SUPPORT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 4 (flags)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 console_flags: 0x3 (
|
||||||
|
REQUIRE_CONSOLE |
|
||||||
|
EGA_SUPPORT
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 1 (information request)
|
||||||
|
u16 flags: 0x1 (
|
||||||
|
OPTIONAL
|
||||||
|
)
|
||||||
|
u32 size: 12
|
||||||
|
u32 mbi_tag_types[]: [
|
||||||
|
0 (none)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 0 (none)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 8
|
||||||
|
}
|
100
fixtures/multiboot2_header_example2.txt
Normal file
100
fixtures/multiboot2_header_example2.txt
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
Multiboot 2 header {
|
||||||
|
u32 magic: 0xe85250d6
|
||||||
|
u32 arch: 0 (i386)
|
||||||
|
u32 size: 272
|
||||||
|
u32 checksum: 0x17adae1a
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 1 (information request)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 96
|
||||||
|
u32 mbi_tag_types[]: [
|
||||||
|
0 (none)
|
||||||
|
1 (boot cmd line)
|
||||||
|
2 (boot loader name)
|
||||||
|
3 (module)
|
||||||
|
4 (basic memory info)
|
||||||
|
5 (BIOS boot device)
|
||||||
|
6 (memory map)
|
||||||
|
7 (VBE info)
|
||||||
|
8 (framebuffer info)
|
||||||
|
9 (ELF symbols)
|
||||||
|
10 (APM table)
|
||||||
|
11 (EFI 32bit system table ptr)
|
||||||
|
12 (EFI 64bit system table ptr)
|
||||||
|
13 (SMBIOS tables)
|
||||||
|
14 (ACPI old RSDP)
|
||||||
|
15 (ACPI new RSDP)
|
||||||
|
16 (networking info)
|
||||||
|
17 (EFI memory map)
|
||||||
|
18 (EFI boot services not terminated)
|
||||||
|
19 (EFI 32bit image handle ptr)
|
||||||
|
20 (EFI 64bit image handle ptr)
|
||||||
|
21 (image load base phys addr)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 2 (address)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 24
|
||||||
|
u32 header_addr: 0xcafebabe
|
||||||
|
u32 load_addr: 0xdeadbeaf
|
||||||
|
u32 load_end_addr: 0xdeadbabe
|
||||||
|
u32 bss_end_addr: 0xcafebeaf
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 3 (entry address)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 entry_addr: 0xcafebabe
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 4 (flags)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 console_flags: 0x0 ()
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 5 (framebuffer)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 20
|
||||||
|
u32 width: 80
|
||||||
|
u32 height: 25
|
||||||
|
u32 depth: 8
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 6 (module alignment)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 8
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 7 (EFI boot services)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 8
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 8 (EFI i386 entry address)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 entry_addr: 0xcafebabe
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 9 (EFI amd64 entry address)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 12
|
||||||
|
u32 entry_addr: 0xdeadbeaf
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 10 (relocatable header)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 24
|
||||||
|
u32 min_addr: 0xcafebabe
|
||||||
|
u32 max_addr: 0xdeadbeaf
|
||||||
|
u32 align: 8
|
||||||
|
u32 preference: 1 (lowest)
|
||||||
|
}
|
||||||
|
Multiboot 2 header tag {
|
||||||
|
u16 type: 0 (none)
|
||||||
|
u16 flags: 0x0 ()
|
||||||
|
u32 size: 8
|
||||||
|
}
|
8
fixtures/multiboot2_info_example0.txt
Normal file
8
fixtures/multiboot2_info_example0.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
Multiboot 2 info {
|
||||||
|
u32 size: 16
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 0 (none)
|
||||||
|
u32 size: 8
|
||||||
|
}
|
129
fixtures/multiboot2_info_example1.txt
Normal file
129
fixtures/multiboot2_info_example1.txt
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
Multiboot 2 info {
|
||||||
|
u32 size: 864
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 21 (image load base phys addr)
|
||||||
|
u32 size: 12
|
||||||
|
u32 load_base_addr: 0x400000
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 1 (boot cmd line)
|
||||||
|
u32 size: 21
|
||||||
|
char cmdline[]: "hello kernel"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 2 (boot loader name)
|
||||||
|
u32 size: 30
|
||||||
|
char name[]: "GRUB 2.02-2ubuntu8.20"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 10 (APM table)
|
||||||
|
u32 size: 28
|
||||||
|
u16 version: 258
|
||||||
|
u16 cseg: 61440
|
||||||
|
u32 offset: 54479
|
||||||
|
u16 cseg_16: 61440
|
||||||
|
u16 dseg: 61440
|
||||||
|
u16 flags: 3
|
||||||
|
u16 cseg_len: 65520
|
||||||
|
u16 cseg_16_len: 65520
|
||||||
|
u16 dseg_len: 65520
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 3 (module)
|
||||||
|
u32 size: 29
|
||||||
|
u32 mod_start: 0x102000
|
||||||
|
u32 mod_end: 0x10329c
|
||||||
|
char cmdline[]: "hello module"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 3 (module)
|
||||||
|
u32 size: 17
|
||||||
|
u32 mod_start: 0x104000
|
||||||
|
u32 mod_end: 0x105254
|
||||||
|
char cmdline[]: ""
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 6 (memory map)
|
||||||
|
u32 size: 160
|
||||||
|
u32 entry_size: 24
|
||||||
|
u32 entry_version: 0
|
||||||
|
varies(entry_size) entries[]: [
|
||||||
|
[0] entry: {
|
||||||
|
u64 base_addr: 0x0
|
||||||
|
u64 length: 654336
|
||||||
|
u32 type: 1
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[1] entry: {
|
||||||
|
u64 base_addr: 0x9fc00
|
||||||
|
u64 length: 1024
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[2] entry: {
|
||||||
|
u64 base_addr: 0xf0000
|
||||||
|
u64 length: 65536
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[3] entry: {
|
||||||
|
u64 base_addr: 0x100000
|
||||||
|
u64 length: 133038080
|
||||||
|
u32 type: 1
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[4] entry: {
|
||||||
|
u64 base_addr: 0x7fe0000
|
||||||
|
u64 length: 131072
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[5] entry: {
|
||||||
|
u64 base_addr: 0xfffc0000
|
||||||
|
u64 length: 262144
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 9 (ELF symbols)
|
||||||
|
u32 size: 420
|
||||||
|
u32 num: 10
|
||||||
|
u32 entsize: 40
|
||||||
|
u32 shndx: 9
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 4 (basic memory info)
|
||||||
|
u32 size: 16
|
||||||
|
u32 mem_lower: 639
|
||||||
|
u32 mem_upper: 129920
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 5 (BIOS boot device)
|
||||||
|
u32 size: 20
|
||||||
|
u32 biosdev: 224
|
||||||
|
u32 partition: 4294967295
|
||||||
|
u32 sub_partition: 4294967295
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 8 (framebuffer info)
|
||||||
|
u32 size: 32
|
||||||
|
u64 framebuffer_addr: 0xb8000
|
||||||
|
u32 framebuffer_pitch: 160
|
||||||
|
u32 framebuffer_width: 80
|
||||||
|
u32 framebuffer_height: 25
|
||||||
|
u8 framebuffer_bpp: 16
|
||||||
|
u8 framebuffer_type: 2
|
||||||
|
u16 reserved: 0x0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 14 (ACPI old RSDP)
|
||||||
|
u32 size: 28
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 0 (none)
|
||||||
|
u32 size: 8
|
||||||
|
}
|
234
fixtures/multiboot2_info_example2.txt
Normal file
234
fixtures/multiboot2_info_example2.txt
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
Multiboot 2 info {
|
||||||
|
u32 size: 1816
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 1 (boot cmd line)
|
||||||
|
u32 size: 23
|
||||||
|
char cmdline[]: "Hello, Kernel!"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 2 (boot loader name)
|
||||||
|
u32 size: 30
|
||||||
|
char name[]: "GRUB 2.02-2ubuntu8.20"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 3 (module)
|
||||||
|
u32 size: 33
|
||||||
|
u32 mod_start: 0x7b
|
||||||
|
u32 mod_end: 0x1c8
|
||||||
|
char cmdline[]: "Hello, Module 1!"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 3 (module)
|
||||||
|
u32 size: 33
|
||||||
|
u32 mod_start: 0x7b
|
||||||
|
u32 mod_end: 0x1c8
|
||||||
|
char cmdline[]: "Hello, Module 2!"
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 4 (basic memory info)
|
||||||
|
u32 size: 16
|
||||||
|
u32 mem_lower: 123
|
||||||
|
u32 mem_upper: 456
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 5 (BIOS boot device)
|
||||||
|
u32 size: 20
|
||||||
|
u32 biosdev: 0
|
||||||
|
u32 partition: 1
|
||||||
|
u32 sub_partition: 2
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 6 (memory map)
|
||||||
|
u32 size: 160
|
||||||
|
u32 entry_size: 24
|
||||||
|
u32 entry_version: 0
|
||||||
|
varies(entry_size) entries[]: [
|
||||||
|
[0] entry: {
|
||||||
|
u64 base_addr: 0x0
|
||||||
|
u64 length: 654336
|
||||||
|
u32 type: 1
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[1] entry: {
|
||||||
|
u64 base_addr: 0x9fc00
|
||||||
|
u64 length: 1024
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[2] entry: {
|
||||||
|
u64 base_addr: 0xf0000
|
||||||
|
u64 length: 65536
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[3] entry: {
|
||||||
|
u64 base_addr: 0x100000
|
||||||
|
u64 length: 133038080
|
||||||
|
u32 type: 1
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[4] entry: {
|
||||||
|
u64 base_addr: 0x7fe0000
|
||||||
|
u64 length: 131072
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
[5] entry: {
|
||||||
|
u64 base_addr: 0xfffc0000
|
||||||
|
u64 length: 262144
|
||||||
|
u32 type: 2
|
||||||
|
u32 reserved: 0x0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 7 (VBE info)
|
||||||
|
u32 size: 784
|
||||||
|
u16 vbe_mode: 0
|
||||||
|
u16 vbe_interface_seg: 123
|
||||||
|
u16 vbe_interface_off: 456
|
||||||
|
u16 vbe_interface_len: 789
|
||||||
|
u8 vbe_control_info[]: [
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 123
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
]
|
||||||
|
u8 vbe_mode_info[]: [
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 8 (framebuffer info)
|
||||||
|
u32 size: 40
|
||||||
|
u64 framebuffer_addr: 0x7b
|
||||||
|
u32 framebuffer_pitch: 456
|
||||||
|
u32 framebuffer_width: 123
|
||||||
|
u32 framebuffer_height: 456
|
||||||
|
u8 framebuffer_bpp: 8
|
||||||
|
u8 framebuffer_type: 1
|
||||||
|
u16 reserved: 0x0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 9 (ELF symbols)
|
||||||
|
u32 size: 420
|
||||||
|
u32 num: 10
|
||||||
|
u32 entsize: 40
|
||||||
|
u32 shndx: 9
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 10 (APM table)
|
||||||
|
u32 size: 28
|
||||||
|
u16 version: 0
|
||||||
|
u16 cseg: 123
|
||||||
|
u32 offset: 456
|
||||||
|
u16 cseg_16: 789
|
||||||
|
u16 dseg: 123
|
||||||
|
u16 flags: 1
|
||||||
|
u16 cseg_len: 456
|
||||||
|
u16 cseg_16_len: 789
|
||||||
|
u16 dseg_len: 123
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 11 (EFI 32bit system table ptr)
|
||||||
|
u32 size: 12
|
||||||
|
u32 pointer: 0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 12 (EFI 64bit system table ptr)
|
||||||
|
u32 size: 16
|
||||||
|
u64 pointer: 0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 13 (SMBIOS tables)
|
||||||
|
u32 size: 24
|
||||||
|
u8 major: 1
|
||||||
|
u8 minor: 2
|
||||||
|
u8 reserved[6]: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 14 (ACPI old RSDP)
|
||||||
|
u32 size: 16
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 15 (ACPI new RSDP)
|
||||||
|
u32 size: 16
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 16 (networking info)
|
||||||
|
u32 size: 16
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 17 (EFI memory map)
|
||||||
|
u32 size: 24
|
||||||
|
u32 descriptor_size: 123
|
||||||
|
u32 descriptor_version: 1
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 18 (EFI boot services not terminated)
|
||||||
|
u32 size: 8
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 19 (EFI 32bit image handle ptr)
|
||||||
|
u32 size: 12
|
||||||
|
u32 pointer: 0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 20 (EFI 64bit image handle ptr)
|
||||||
|
u32 size: 16
|
||||||
|
u64 pointer: 0
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 21 (image load base phys addr)
|
||||||
|
u32 size: 12
|
||||||
|
u32 load_base_addr: 0x7b
|
||||||
|
}
|
||||||
|
Multiboot 2 info tag {
|
||||||
|
u32 type: 0 (none)
|
||||||
|
u32 size: 8
|
||||||
|
}
|
1
include/.gitignore
vendored
Normal file
1
include/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/kernaux/version.h
|
33
tests/.gitignore
vendored
Normal file
33
tests/.gitignore
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/multiboot2_header_print0
|
||||||
|
/multiboot2_header_print1
|
||||||
|
/multiboot2_header_print2
|
||||||
|
/multiboot2_info_print0
|
||||||
|
/multiboot2_info_print1
|
||||||
|
/multiboot2_info_print2
|
||||||
|
/test_arch_i386
|
||||||
|
/test_cmdline
|
||||||
|
/test_cmdline_gen
|
||||||
|
/test_cmdline_gen.c
|
||||||
|
/test_elf
|
||||||
|
/test_free_list
|
||||||
|
/test_mbr
|
||||||
|
/test_memmap
|
||||||
|
/test_multiboot2_common_packing
|
||||||
|
/test_multiboot2_header_helpers
|
||||||
|
/test_multiboot2_header_print
|
||||||
|
/test_multiboot2_header_print.c
|
||||||
|
/test_multiboot2_header_validation
|
||||||
|
/test_multiboot2_info_helpers
|
||||||
|
/test_multiboot2_info_print
|
||||||
|
/test_multiboot2_info_print.c
|
||||||
|
/test_multiboot2_info_validation
|
||||||
|
/test_ntoa
|
||||||
|
/test_ntoa_assert
|
||||||
|
/test_pfa
|
||||||
|
/test_pfa_assert
|
||||||
|
/test_printf
|
||||||
|
/test_printf_fmt_gen
|
||||||
|
/test_printf_fmt_gen.c
|
||||||
|
/test_printf_gen
|
||||||
|
/test_printf_gen.c
|
||||||
|
/test_units_human
|
|
@ -14,7 +14,7 @@ multiboot2_header_print0_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_header_print0_SOURCES = \
|
multiboot2_header_print0_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
multiboot2_header_print0.c \
|
multiboot2_header_print0.c \
|
||||||
multiboot2_header_example0.h
|
../fixtures/multiboot2_header_example0.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
@ -27,7 +27,7 @@ multiboot2_header_print1_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_header_print1_SOURCES = \
|
multiboot2_header_print1_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
multiboot2_header_print1.c \
|
multiboot2_header_print1.c \
|
||||||
multiboot2_header_example1.h
|
../fixtures/multiboot2_header_example1.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
############################
|
############################
|
||||||
|
@ -40,7 +40,7 @@ multiboot2_header_print2_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_header_print2_SOURCES = \
|
multiboot2_header_print2_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
multiboot2_header_print2.c \
|
multiboot2_header_print2.c \
|
||||||
multiboot2_header_example2.h
|
../fixtures/multiboot2_header_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -53,7 +53,7 @@ multiboot2_info_print0_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_info_print0_SOURCES = \
|
multiboot2_info_print0_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
multiboot2_info_print0.c \
|
multiboot2_info_print0.c \
|
||||||
multiboot2_info_example0.h
|
../fixtures/multiboot2_info_example0.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -66,7 +66,7 @@ multiboot2_info_print1_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_info_print1_SOURCES = \
|
multiboot2_info_print1_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
multiboot2_info_print1.c \
|
multiboot2_info_print1.c \
|
||||||
multiboot2_info_example1.h
|
../fixtures/multiboot2_info_example1.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
|
@ -79,7 +79,7 @@ multiboot2_info_print2_LDADD = $(top_builddir)/libkernaux.la
|
||||||
multiboot2_info_print2_SOURCES = \
|
multiboot2_info_print2_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
multiboot2_info_print2.c \
|
multiboot2_info_print2.c \
|
||||||
multiboot2_info_example2.h
|
../fixtures/multiboot2_info_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
@ -121,7 +121,7 @@ test_cmdline_gen_SOURCES = \
|
||||||
test_cmdline_gen.c \
|
test_cmdline_gen.c \
|
||||||
cmdline_gen.py \
|
cmdline_gen.py \
|
||||||
cmdline_gen.jinja \
|
cmdline_gen.jinja \
|
||||||
$(top_srcdir)/common/cmdline.yml \
|
$(top_srcdir)/fixtures/cmdline.yml \
|
||||||
cmdline_test.h \
|
cmdline_test.h \
|
||||||
cmdline_test.c
|
cmdline_test.c
|
||||||
endif
|
endif
|
||||||
|
@ -129,8 +129,8 @@ endif
|
||||||
|
|
||||||
CLEANFILES += test_cmdline_gen.c
|
CLEANFILES += test_cmdline_gen.c
|
||||||
|
|
||||||
test_cmdline_gen.c: $(top_srcdir)/tests/cmdline_gen.py $(top_srcdir)/tests/cmdline_gen.jinja $(top_srcdir)/common/cmdline.yml
|
test_cmdline_gen.c: $(top_srcdir)/tests/cmdline_gen.py $(top_srcdir)/tests/cmdline_gen.jinja $(top_srcdir)/fixtures/cmdline.yml
|
||||||
$(PYTHON) $(top_srcdir)/tests/cmdline_gen.py $(top_srcdir)/tests/cmdline_gen.jinja $(top_srcdir)/common/cmdline.yml test_cmdline_gen.c
|
$(PYTHON) $(top_srcdir)/tests/cmdline_gen.py $(top_srcdir)/tests/cmdline_gen.jinja $(top_srcdir)/fixtures/cmdline.yml test_cmdline_gen.c
|
||||||
|
|
||||||
############
|
############
|
||||||
# test_elf #
|
# test_elf #
|
||||||
|
@ -190,8 +190,8 @@ test_multiboot2_common_packing_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_common_packing_SOURCES = \
|
test_multiboot2_common_packing_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
test_multiboot2_common_packing.c \
|
test_multiboot2_common_packing.c \
|
||||||
multiboot2_header_example2.h \
|
../fixtures/multiboot2_header_example2.h \
|
||||||
multiboot2_info_example2.h
|
../fixtures/multiboot2_info_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
|
@ -204,8 +204,8 @@ test_multiboot2_header_helpers_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_header_helpers_SOURCES = \
|
test_multiboot2_header_helpers_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
test_multiboot2_header_helpers.c \
|
test_multiboot2_header_helpers.c \
|
||||||
multiboot2_header_example1.h \
|
../fixtures/multiboot2_header_example1.h \
|
||||||
multiboot2_header_example2.h
|
../fixtures/multiboot2_header_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
################################
|
################################
|
||||||
|
@ -217,7 +217,10 @@ TESTS += test_multiboot2_header_print
|
||||||
test_multiboot2_header_print_DEPENDENCIES = \
|
test_multiboot2_header_print_DEPENDENCIES = \
|
||||||
multiboot2_header_print0 \
|
multiboot2_header_print0 \
|
||||||
multiboot2_header_print1 \
|
multiboot2_header_print1 \
|
||||||
multiboot2_header_print2
|
multiboot2_header_print2 \
|
||||||
|
../fixtures/multiboot2_header_example0.txt \
|
||||||
|
../fixtures/multiboot2_header_example1.txt \
|
||||||
|
../fixtures/multiboot2_header_example2.txt
|
||||||
test_multiboot2_header_print_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_header_print_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_header_print_SOURCES = \
|
test_multiboot2_header_print_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
|
@ -234,8 +237,8 @@ test_multiboot2_header_validation_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_header_validation_SOURCES = \
|
test_multiboot2_header_validation_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
test_multiboot2_header_validation.c \
|
test_multiboot2_header_validation.c \
|
||||||
multiboot2_header_example1.h \
|
../fixtures/multiboot2_header_example1.h \
|
||||||
multiboot2_header_example2.h
|
../fixtures/multiboot2_header_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
################################
|
################################
|
||||||
|
@ -248,8 +251,8 @@ test_multiboot2_info_helpers_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_info_helpers_SOURCES = \
|
test_multiboot2_info_helpers_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
test_multiboot2_info_helpers.c \
|
test_multiboot2_info_helpers.c \
|
||||||
multiboot2_info_example1.h \
|
../fixtures/multiboot2_info_example1.h \
|
||||||
multiboot2_info_example2.h
|
../fixtures/multiboot2_info_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
|
@ -261,7 +264,10 @@ TESTS += test_multiboot2_info_print
|
||||||
test_multiboot2_info_print_DEPENDENCIES = \
|
test_multiboot2_info_print_DEPENDENCIES = \
|
||||||
multiboot2_info_print0 \
|
multiboot2_info_print0 \
|
||||||
multiboot2_info_print1 \
|
multiboot2_info_print1 \
|
||||||
multiboot2_info_print2
|
multiboot2_info_print2 \
|
||||||
|
../fixtures/multiboot2_info_example0.txt \
|
||||||
|
../fixtures/multiboot2_info_example1.txt \
|
||||||
|
../fixtures/multiboot2_info_example2.txt
|
||||||
test_multiboot2_info_print_LDADD = $(top_builddir)/libkernaux.la
|
test_multiboot2_info_print_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_info_print_SOURCES = \
|
test_multiboot2_info_print_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
|
@ -278,8 +284,8 @@ test_multiboot2_info_validation_LDADD = $(top_builddir)/libkernaux.la
|
||||||
test_multiboot2_info_validation_SOURCES = \
|
test_multiboot2_info_validation_SOURCES = \
|
||||||
main.c \
|
main.c \
|
||||||
test_multiboot2_info_validation.c \
|
test_multiboot2_info_validation.c \
|
||||||
multiboot2_info_example1.h \
|
../fixtures/multiboot2_info_example1.h \
|
||||||
multiboot2_info_example2.h
|
../fixtures/multiboot2_info_example2.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#############
|
#############
|
||||||
|
@ -359,14 +365,14 @@ test_printf_fmt_gen_SOURCES = \
|
||||||
test_printf_fmt_gen.c \
|
test_printf_fmt_gen.c \
|
||||||
printf_fmt_gen.py \
|
printf_fmt_gen.py \
|
||||||
printf_fmt_gen.jinja \
|
printf_fmt_gen.jinja \
|
||||||
$(top_srcdir)/common/printf_fmt.yml
|
$(top_srcdir)/fixtures/printf_fmt.yml
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CLEANFILES += test_printf_fmt_gen.c
|
CLEANFILES += test_printf_fmt_gen.c
|
||||||
|
|
||||||
test_printf_fmt_gen.c: $(top_srcdir)/tests/printf_fmt_gen.py $(top_srcdir)/tests/printf_fmt_gen.jinja $(top_srcdir)/common/printf_fmt.yml
|
test_printf_fmt_gen.c: $(top_srcdir)/tests/printf_fmt_gen.py $(top_srcdir)/tests/printf_fmt_gen.jinja $(top_srcdir)/fixtures/printf_fmt.yml
|
||||||
$(PYTHON) $(top_srcdir)/tests/printf_fmt_gen.py $(top_srcdir)/tests/printf_fmt_gen.jinja $(top_srcdir)/common/printf_fmt.yml test_printf_fmt_gen.c
|
$(PYTHON) $(top_srcdir)/tests/printf_fmt_gen.py $(top_srcdir)/tests/printf_fmt_gen.jinja $(top_srcdir)/fixtures/printf_fmt.yml test_printf_fmt_gen.c
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# test_printf_gen #
|
# test_printf_gen #
|
||||||
|
@ -381,15 +387,15 @@ test_printf_gen_SOURCES = \
|
||||||
test_printf_gen.c \
|
test_printf_gen.c \
|
||||||
printf_gen.py \
|
printf_gen.py \
|
||||||
printf_gen.jinja \
|
printf_gen.jinja \
|
||||||
$(top_srcdir)/common/printf.yml \
|
$(top_srcdir)/fixtures/printf.yml \
|
||||||
$(top_srcdir)/common/printf_orig.yml
|
$(top_srcdir)/fixtures/printf_orig.yml
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CLEANFILES += test_printf_gen.c
|
CLEANFILES += test_printf_gen.c
|
||||||
|
|
||||||
test_printf_gen.c: $(top_srcdir)/tests/printf_gen.py $(top_srcdir)/tests/printf_gen.jinja $(top_srcdir)/common/printf.yml $(top_srcdir)/common/printf_orig.yml
|
test_printf_gen.c: $(top_srcdir)/tests/printf_gen.py $(top_srcdir)/tests/printf_gen.jinja $(top_srcdir)/fixtures/printf.yml $(top_srcdir)/fixtures/printf_orig.yml
|
||||||
$(PYTHON) $(top_srcdir)/tests/printf_gen.py $(top_srcdir)/tests/printf_gen.jinja $(top_srcdir)/common/printf.yml $(top_srcdir)/common/printf_orig.yml test_printf_gen.c
|
$(PYTHON) $(top_srcdir)/tests/printf_gen.py $(top_srcdir)/tests/printf_gen.jinja $(top_srcdir)/fixtures/printf.yml $(top_srcdir)/fixtures/printf_orig.yml test_printf_gen.c
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# test_units_human #
|
# test_units_human #
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "multiboot2_header_example0.h"
|
#include "../fixtures/multiboot2_header_example0.h"
|
||||||
|
|
||||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "multiboot2_header_example1.h"
|
#include "../fixtures/multiboot2_header_example1.h"
|
||||||
|
|
||||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "multiboot2_header_example2.h"
|
#include "../fixtures/multiboot2_header_example2.h"
|
||||||
|
|
||||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "multiboot2_info_example0.h"
|
#include "../fixtures/multiboot2_info_example0.h"
|
||||||
|
|
||||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "multiboot2_info_example1.h"
|
#include "../fixtures/multiboot2_info_example1.h"
|
||||||
|
|
||||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "multiboot2_info_example2.h"
|
#include "../fixtures/multiboot2_info_example2.h"
|
||||||
|
|
||||||
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
static void my_putc(void *display KERNAUX_UNUSED, char c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "multiboot2_header_example2.h"
|
#include "../fixtures/multiboot2_header_example2.h"
|
||||||
#include "multiboot2_info_example2.h"
|
#include "../fixtures/multiboot2_info_example2.h"
|
||||||
|
|
||||||
#define HEAD_SIZEOF1(type, inst, size) \
|
#define HEAD_SIZEOF1(type, inst, size) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#include <kernaux/multiboot2.h>
|
#include <kernaux/multiboot2.h>
|
||||||
|
|
||||||
#include "multiboot2_header_example1.h"
|
#include "../fixtures/multiboot2_header_example1.h"
|
||||||
#include "multiboot2_header_example2.h"
|
#include "../fixtures/multiboot2_header_example2.h"
|
||||||
|
|
||||||
void test_main()
|
void test_main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,218 +0,0 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#ifndef __USE_POSIX2
|
|
||||||
#define __USE_POSIX2
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static const char output0[] =
|
|
||||||
"Multiboot 2 header {\n"
|
|
||||||
" u32 magic: 0xe85250d6\n"
|
|
||||||
" u32 arch: 0 (i386)\n"
|
|
||||||
" u32 size: 24\n"
|
|
||||||
" u32 checksum: 0x17adaf12\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 0 (none)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char output1[] =
|
|
||||||
"Multiboot 2 header {\n"
|
|
||||||
" u32 magic: 0xe85250d6\n"
|
|
||||||
" u32 arch: 4 (MIPS32)\n"
|
|
||||||
" u32 size: 104\n"
|
|
||||||
" u32 checksum: 0x17adaebe\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 4 (flags)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 console_flags: 0x0 ()\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 4 (flags)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 console_flags: 0x1 (\n"
|
|
||||||
" REQUIRE_CONSOLE\n"
|
|
||||||
" )\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 4 (flags)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 console_flags: 0x2 (\n"
|
|
||||||
" EGA_SUPPORT\n"
|
|
||||||
" )\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 4 (flags)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 console_flags: 0x3 (\n"
|
|
||||||
" REQUIRE_CONSOLE |\n"
|
|
||||||
" EGA_SUPPORT\n"
|
|
||||||
" )\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 1 (information request)\n"
|
|
||||||
" u16 flags: 0x1 (\n"
|
|
||||||
" OPTIONAL\n"
|
|
||||||
" )\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 mbi_tag_types[]: [\n"
|
|
||||||
" 0 (none)\n"
|
|
||||||
" ]\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 0 (none)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char output2[] =
|
|
||||||
"Multiboot 2 header {\n"
|
|
||||||
" u32 magic: 0xe85250d6\n"
|
|
||||||
" u32 arch: 0 (i386)\n"
|
|
||||||
" u32 size: 272\n"
|
|
||||||
" u32 checksum: 0x17adae1a\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 1 (information request)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 96\n"
|
|
||||||
" u32 mbi_tag_types[]: [\n"
|
|
||||||
" 0 (none)\n"
|
|
||||||
" 1 (boot cmd line)\n"
|
|
||||||
" 2 (boot loader name)\n"
|
|
||||||
" 3 (module)\n"
|
|
||||||
" 4 (basic memory info)\n"
|
|
||||||
" 5 (BIOS boot device)\n"
|
|
||||||
" 6 (memory map)\n"
|
|
||||||
" 7 (VBE info)\n"
|
|
||||||
" 8 (framebuffer info)\n"
|
|
||||||
" 9 (ELF symbols)\n"
|
|
||||||
" 10 (APM table)\n"
|
|
||||||
" 11 (EFI 32bit system table ptr)\n"
|
|
||||||
" 12 (EFI 64bit system table ptr)\n"
|
|
||||||
" 13 (SMBIOS tables)\n"
|
|
||||||
" 14 (ACPI old RSDP)\n"
|
|
||||||
" 15 (ACPI new RSDP)\n"
|
|
||||||
" 16 (networking info)\n"
|
|
||||||
" 17 (EFI memory map)\n"
|
|
||||||
" 18 (EFI boot services not terminated)\n"
|
|
||||||
" 19 (EFI 32bit image handle ptr)\n"
|
|
||||||
" 20 (EFI 64bit image handle ptr)\n"
|
|
||||||
" 21 (image load base phys addr)\n"
|
|
||||||
" ]\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 2 (address)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 24\n"
|
|
||||||
" u32 header_addr: 0xcafebabe\n"
|
|
||||||
" u32 load_addr: 0xdeadbeaf\n"
|
|
||||||
" u32 load_end_addr: 0xdeadbabe\n"
|
|
||||||
" u32 bss_end_addr: 0xcafebeaf\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 3 (entry address)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 entry_addr: 0xcafebabe\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 4 (flags)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 console_flags: 0x0 ()\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 5 (framebuffer)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 20\n"
|
|
||||||
" u32 width: 80\n"
|
|
||||||
" u32 height: 25\n"
|
|
||||||
" u32 depth: 8\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 6 (module alignment)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 7 (EFI boot services)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 8 (EFI i386 entry address)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 entry_addr: 0xcafebabe\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 9 (EFI amd64 entry address)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 entry_addr: 0xdeadbeaf\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 10 (relocatable header)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 24\n"
|
|
||||||
" u32 min_addr: 0xcafebabe\n"
|
|
||||||
" u32 max_addr: 0xdeadbeaf\n"
|
|
||||||
" u32 align: 8\n"
|
|
||||||
" u32 preference: 1 (lowest)\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 header tag {\n"
|
|
||||||
" u16 type: 0 (none)\n"
|
|
||||||
" u16 flags: 0x0 ()\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
void test_main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
FILE *const fd = popen("./multiboot2_header_print0", "r");
|
|
||||||
assert(fd != NULL);
|
|
||||||
|
|
||||||
for (const char *ch = output0; *ch; ++ch) {
|
|
||||||
assert(fgetc(fd) == *ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int status = pclose(fd);
|
|
||||||
assert(status == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
FILE *const fd = popen("./multiboot2_header_print1", "r");
|
|
||||||
assert(fd != NULL);
|
|
||||||
|
|
||||||
for (const char *ch = output1; *ch; ++ch) {
|
|
||||||
assert(fgetc(fd) == *ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int status = pclose(fd);
|
|
||||||
assert(status == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
FILE *const fd = popen("./multiboot2_header_print2", "r");
|
|
||||||
assert(fd != NULL);
|
|
||||||
|
|
||||||
for (const char *ch = output2; *ch; ++ch) {
|
|
||||||
assert(fgetc(fd) == *ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int status = pclose(fd);
|
|
||||||
assert(status == 0);
|
|
||||||
}
|
|
||||||
}
|
|
61
tests/test_multiboot2_header_print.c.in
Normal file
61
tests/test_multiboot2_header_print.c.in
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef __USE_POSIX2
|
||||||
|
#define __USE_POSIX2
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void test_main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
FILE *const print_file =
|
||||||
|
popen("@abs_top_builddir@/tests/multiboot2_header_print0", "r");
|
||||||
|
FILE *const text_file =
|
||||||
|
fopen("@abs_top_srcdir@/fixtures/multiboot2_header_example0.txt", "r");
|
||||||
|
assert(print_file != NULL);
|
||||||
|
assert(text_file != NULL);
|
||||||
|
|
||||||
|
while (!feof(text_file)) {
|
||||||
|
assert(fgetc(print_file) == fgetc(text_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pclose(print_file) == 0);
|
||||||
|
assert(fclose(text_file) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FILE *const print_file =
|
||||||
|
popen("@abs_top_builddir@/tests/multiboot2_header_print1", "r");
|
||||||
|
FILE *const text_file =
|
||||||
|
fopen("@abs_top_srcdir@/fixtures/multiboot2_header_example1.txt", "r");
|
||||||
|
assert(print_file != NULL);
|
||||||
|
assert(text_file != NULL);
|
||||||
|
|
||||||
|
while (!feof(text_file)) {
|
||||||
|
assert(fgetc(print_file) == fgetc(text_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pclose(print_file) == 0);
|
||||||
|
assert(fclose(text_file) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FILE *const print_file =
|
||||||
|
popen("@abs_top_builddir@/tests/multiboot2_header_print2", "r");
|
||||||
|
FILE *const text_file =
|
||||||
|
fopen("@abs_top_srcdir@/fixtures/multiboot2_header_example2.txt", "r");
|
||||||
|
assert(print_file != NULL);
|
||||||
|
assert(text_file != NULL);
|
||||||
|
|
||||||
|
while (!feof(text_file)) {
|
||||||
|
assert(fgetc(print_file) == fgetc(text_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pclose(print_file) == 0);
|
||||||
|
assert(fclose(text_file) == 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "multiboot2_info_example1.h"
|
#include "../fixtures/multiboot2_info_example1.h"
|
||||||
#include "multiboot2_info_example2.h"
|
#include "../fixtures/multiboot2_info_example2.h"
|
||||||
|
|
||||||
#include <kernaux/macro/packing_start.run>
|
#include <kernaux/macro/packing_start.run>
|
||||||
|
|
||||||
|
|
|
@ -1,441 +0,0 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifndef __USE_POSIX2
|
|
||||||
#define __USE_POSIX2
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
static const char output0[] =
|
|
||||||
"Multiboot 2 info {\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 0 (none)\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char output1[] =
|
|
||||||
"Multiboot 2 info {\n"
|
|
||||||
" u32 size: 864\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 21 (image load base phys addr)\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 load_base_addr: 0x400000\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 1 (boot cmd line)\n"
|
|
||||||
" u32 size: 21\n"
|
|
||||||
" char cmdline[]: \"hello kernel\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 2 (boot loader name)\n"
|
|
||||||
" u32 size: 30\n"
|
|
||||||
" char name[]: \"GRUB 2.02-2ubuntu8.20\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 10 (APM table)\n"
|
|
||||||
" u32 size: 28\n"
|
|
||||||
" u16 version: 258\n"
|
|
||||||
" u16 cseg: 61440\n"
|
|
||||||
" u32 offset: 54479\n"
|
|
||||||
" u16 cseg_16: 61440\n"
|
|
||||||
" u16 dseg: 61440\n"
|
|
||||||
" u16 flags: 3\n"
|
|
||||||
" u16 cseg_len: 65520\n"
|
|
||||||
" u16 cseg_16_len: 65520\n"
|
|
||||||
" u16 dseg_len: 65520\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 3 (module)\n"
|
|
||||||
" u32 size: 29\n"
|
|
||||||
" u32 mod_start: 0x102000\n"
|
|
||||||
" u32 mod_end: 0x10329c\n"
|
|
||||||
" char cmdline[]: \"hello module\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 3 (module)\n"
|
|
||||||
" u32 size: 17\n"
|
|
||||||
" u32 mod_start: 0x104000\n"
|
|
||||||
" u32 mod_end: 0x105254\n"
|
|
||||||
" char cmdline[]: \"\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 6 (memory map)\n"
|
|
||||||
" u32 size: 160\n"
|
|
||||||
" u32 entry_size: 24\n"
|
|
||||||
" u32 entry_version: 0\n"
|
|
||||||
" varies(entry_size) entries[]: [\n"
|
|
||||||
" [0] entry: {\n"
|
|
||||||
" u64 base_addr: 0x0\n"
|
|
||||||
" u64 length: 654336\n"
|
|
||||||
" u32 type: 1\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [1] entry: {\n"
|
|
||||||
" u64 base_addr: 0x9fc00\n"
|
|
||||||
" u64 length: 1024\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [2] entry: {\n"
|
|
||||||
" u64 base_addr: 0xf0000\n"
|
|
||||||
" u64 length: 65536\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [3] entry: {\n"
|
|
||||||
" u64 base_addr: 0x100000\n"
|
|
||||||
" u64 length: 133038080\n"
|
|
||||||
" u32 type: 1\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [4] entry: {\n"
|
|
||||||
" u64 base_addr: 0x7fe0000\n"
|
|
||||||
" u64 length: 131072\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [5] entry: {\n"
|
|
||||||
" u64 base_addr: 0xfffc0000\n"
|
|
||||||
" u64 length: 262144\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" ]\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 9 (ELF symbols)\n"
|
|
||||||
" u32 size: 420\n"
|
|
||||||
" u32 num: 10\n"
|
|
||||||
" u32 entsize: 40\n"
|
|
||||||
" u32 shndx: 9\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 4 (basic memory info)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
" u32 mem_lower: 639\n"
|
|
||||||
" u32 mem_upper: 129920\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 5 (BIOS boot device)\n"
|
|
||||||
" u32 size: 20\n"
|
|
||||||
" u32 biosdev: 224\n"
|
|
||||||
" u32 partition: 4294967295\n"
|
|
||||||
" u32 sub_partition: 4294967295\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 8 (framebuffer info)\n"
|
|
||||||
" u32 size: 32\n"
|
|
||||||
" u64 framebuffer_addr: 0xb8000\n"
|
|
||||||
" u32 framebuffer_pitch: 160\n"
|
|
||||||
" u32 framebuffer_width: 80\n"
|
|
||||||
" u32 framebuffer_height: 25\n"
|
|
||||||
" u8 framebuffer_bpp: 16\n"
|
|
||||||
" u8 framebuffer_type: 2\n"
|
|
||||||
" u16 reserved: 0x0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 14 (ACPI old RSDP)\n"
|
|
||||||
" u32 size: 28\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 0 (none)\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char output2_part1[] =
|
|
||||||
"Multiboot 2 info {\n"
|
|
||||||
" u32 size: 1816\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 1 (boot cmd line)\n"
|
|
||||||
" u32 size: 23\n"
|
|
||||||
" char cmdline[]: \"Hello, Kernel!\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 2 (boot loader name)\n"
|
|
||||||
" u32 size: 30\n"
|
|
||||||
" char name[]: \"GRUB 2.02-2ubuntu8.20\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 3 (module)\n"
|
|
||||||
" u32 size: 33\n"
|
|
||||||
" u32 mod_start: 0x7b\n"
|
|
||||||
" u32 mod_end: 0x1c8\n"
|
|
||||||
" char cmdline[]: \"Hello, Module 1!\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 3 (module)\n"
|
|
||||||
" u32 size: 33\n"
|
|
||||||
" u32 mod_start: 0x7b\n"
|
|
||||||
" u32 mod_end: 0x1c8\n"
|
|
||||||
" char cmdline[]: \"Hello, Module 2!\"\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 4 (basic memory info)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
" u32 mem_lower: 123\n"
|
|
||||||
" u32 mem_upper: 456\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 5 (BIOS boot device)\n"
|
|
||||||
" u32 size: 20\n"
|
|
||||||
" u32 biosdev: 0\n"
|
|
||||||
" u32 partition: 1\n"
|
|
||||||
" u32 sub_partition: 2\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 6 (memory map)\n"
|
|
||||||
" u32 size: 160\n"
|
|
||||||
" u32 entry_size: 24\n"
|
|
||||||
" u32 entry_version: 0\n"
|
|
||||||
" varies(entry_size) entries[]: [\n"
|
|
||||||
" [0] entry: {\n"
|
|
||||||
" u64 base_addr: 0x0\n"
|
|
||||||
" u64 length: 654336\n"
|
|
||||||
" u32 type: 1\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [1] entry: {\n"
|
|
||||||
" u64 base_addr: 0x9fc00\n"
|
|
||||||
" u64 length: 1024\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [2] entry: {\n"
|
|
||||||
" u64 base_addr: 0xf0000\n"
|
|
||||||
" u64 length: 65536\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [3] entry: {\n"
|
|
||||||
" u64 base_addr: 0x100000\n"
|
|
||||||
" u64 length: 133038080\n"
|
|
||||||
" u32 type: 1\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [4] entry: {\n"
|
|
||||||
" u64 base_addr: 0x7fe0000\n"
|
|
||||||
" u64 length: 131072\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" [5] entry: {\n"
|
|
||||||
" u64 base_addr: 0xfffc0000\n"
|
|
||||||
" u64 length: 262144\n"
|
|
||||||
" u32 type: 2\n"
|
|
||||||
" u32 reserved: 0x0\n"
|
|
||||||
" }\n"
|
|
||||||
" ]\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char output2_part2[] =
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 7 (VBE info)\n"
|
|
||||||
" u32 size: 784\n"
|
|
||||||
" u16 vbe_mode: 0\n"
|
|
||||||
" u16 vbe_interface_seg: 123\n"
|
|
||||||
" u16 vbe_interface_off: 456\n"
|
|
||||||
" u16 vbe_interface_len: 789\n"
|
|
||||||
" u8 vbe_control_info[]: [\n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 123\n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" ]\n"
|
|
||||||
" u8 vbe_mode_info[]: [\n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255\n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n"
|
|
||||||
" ]\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
static const char output2_part3[] =
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 8 (framebuffer info)\n"
|
|
||||||
" u32 size: 40\n"
|
|
||||||
" u64 framebuffer_addr: 0x7b\n"
|
|
||||||
" u32 framebuffer_pitch: 456\n"
|
|
||||||
" u32 framebuffer_width: 123\n"
|
|
||||||
" u32 framebuffer_height: 456\n"
|
|
||||||
" u8 framebuffer_bpp: 8\n"
|
|
||||||
" u8 framebuffer_type: 1\n"
|
|
||||||
" u16 reserved: 0x0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 9 (ELF symbols)\n"
|
|
||||||
" u32 size: 420\n"
|
|
||||||
" u32 num: 10\n"
|
|
||||||
" u32 entsize: 40\n"
|
|
||||||
" u32 shndx: 9\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 10 (APM table)\n"
|
|
||||||
" u32 size: 28\n"
|
|
||||||
" u16 version: 0\n"
|
|
||||||
" u16 cseg: 123\n"
|
|
||||||
" u32 offset: 456\n"
|
|
||||||
" u16 cseg_16: 789\n"
|
|
||||||
" u16 dseg: 123\n"
|
|
||||||
" u16 flags: 1\n"
|
|
||||||
" u16 cseg_len: 456\n"
|
|
||||||
" u16 cseg_16_len: 789\n"
|
|
||||||
" u16 dseg_len: 123\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 11 (EFI 32bit system table ptr)\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 pointer: 0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 12 (EFI 64bit system table ptr)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
" u64 pointer: 0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 13 (SMBIOS tables)\n"
|
|
||||||
" u32 size: 24\n"
|
|
||||||
" u8 major: 1\n"
|
|
||||||
" u8 minor: 2\n"
|
|
||||||
" u8 reserved[6]: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0]\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 14 (ACPI old RSDP)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 15 (ACPI new RSDP)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 16 (networking info)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 17 (EFI memory map)\n"
|
|
||||||
" u32 size: 24\n"
|
|
||||||
" u32 descriptor_size: 123\n"
|
|
||||||
" u32 descriptor_version: 1\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 18 (EFI boot services not terminated)\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 19 (EFI 32bit image handle ptr)\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 pointer: 0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 20 (EFI 64bit image handle ptr)\n"
|
|
||||||
" u32 size: 16\n"
|
|
||||||
" u64 pointer: 0\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 21 (image load base phys addr)\n"
|
|
||||||
" u32 size: 12\n"
|
|
||||||
" u32 load_base_addr: 0x7b\n"
|
|
||||||
"}\n"
|
|
||||||
"Multiboot 2 info tag {\n"
|
|
||||||
" u32 type: 0 (none)\n"
|
|
||||||
" u32 size: 8\n"
|
|
||||||
"}\n";
|
|
||||||
|
|
||||||
void test_main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
FILE *const fd = popen("./multiboot2_info_print0", "r");
|
|
||||||
assert(fd != NULL);
|
|
||||||
|
|
||||||
for (const char *ch = output0; *ch; ++ch) {
|
|
||||||
assert(fgetc(fd) == *ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int status = pclose(fd);
|
|
||||||
assert(status == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
FILE *const fd = popen("./multiboot2_info_print1", "r");
|
|
||||||
assert(fd != NULL);
|
|
||||||
|
|
||||||
for (const char *ch = output1; *ch; ++ch) {
|
|
||||||
assert(fgetc(fd) == *ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int status = pclose(fd);
|
|
||||||
assert(status == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const size_t part1_len = strlen(output2_part1);
|
|
||||||
const size_t part2_len = strlen(output2_part2);
|
|
||||||
const size_t part3_len = strlen(output2_part3);
|
|
||||||
char *const output2 = malloc(1 + part1_len + part2_len + part3_len);
|
|
||||||
assert(output2);
|
|
||||||
strcpy(output2, output2_part1);
|
|
||||||
strcat(output2, output2_part2);
|
|
||||||
strcat(output2, output2_part3);
|
|
||||||
|
|
||||||
FILE *const fd = popen("./multiboot2_info_print2", "r");
|
|
||||||
assert(fd != NULL);
|
|
||||||
|
|
||||||
for (const char *ch = output2; *ch; ++ch) {
|
|
||||||
assert(fgetc(fd) == *ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int status = pclose(fd);
|
|
||||||
assert(status == 0);
|
|
||||||
}
|
|
||||||
}
|
|
61
tests/test_multiboot2_info_print.c.in
Normal file
61
tests/test_multiboot2_info_print.c.in
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef __USE_POSIX2
|
||||||
|
#define __USE_POSIX2
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void test_main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
FILE *const print_file =
|
||||||
|
popen("@abs_top_builddir@/tests/multiboot2_info_print0", "r");
|
||||||
|
FILE *const text_file =
|
||||||
|
fopen("@abs_top_srcdir@/fixtures/multiboot2_info_example0.txt", "r");
|
||||||
|
assert(print_file != NULL);
|
||||||
|
assert(text_file != NULL);
|
||||||
|
|
||||||
|
while (!feof(text_file)) {
|
||||||
|
assert(fgetc(print_file) == fgetc(text_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pclose(print_file) == 0);
|
||||||
|
assert(fclose(text_file) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FILE *const print_file =
|
||||||
|
popen("@abs_top_builddir@/tests/multiboot2_info_print1", "r");
|
||||||
|
FILE *const text_file =
|
||||||
|
fopen("@abs_top_srcdir@/fixtures/multiboot2_info_example1.txt", "r");
|
||||||
|
assert(print_file != NULL);
|
||||||
|
assert(text_file != NULL);
|
||||||
|
|
||||||
|
while (!feof(text_file)) {
|
||||||
|
assert(fgetc(print_file) == fgetc(text_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pclose(print_file) == 0);
|
||||||
|
assert(fclose(text_file) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
FILE *const print_file =
|
||||||
|
popen("@abs_top_builddir@/tests/multiboot2_info_print2", "r");
|
||||||
|
FILE *const text_file =
|
||||||
|
fopen("@abs_top_srcdir@/fixtures/multiboot2_info_example2.txt", "r");
|
||||||
|
assert(print_file != NULL);
|
||||||
|
assert(text_file != NULL);
|
||||||
|
|
||||||
|
while (!feof(text_file)) {
|
||||||
|
assert(fgetc(print_file) == fgetc(text_file));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pclose(print_file) == 0);
|
||||||
|
assert(fclose(text_file) == 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "multiboot2_info_example1.h"
|
#include "../fixtures/multiboot2_info_example1.h"
|
||||||
#include "multiboot2_info_example2.h"
|
#include "../fixtures/multiboot2_info_example2.h"
|
||||||
|
|
||||||
#include <kernaux/macro/packing_start.run>
|
#include <kernaux/macro/packing_start.run>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue