Browse Source

Added potential extra tests (001 is a placeholder)

master
Ludovic 'Archivist' Lagouardette 2 years ago
parent
commit
b122bab82c
7 changed files with 302 additions and 1 deletions
  1. +1
    -1
      .gitignore
  2. +5
    -0
      Makefile
  3. +1
    -0
      extra_tests/001_test/.gitignore
  4. +17
    -0
      extra_tests/001_test/Makefile
  5. +186
    -0
      extra_tests/001_test/gp_config.hpp
  6. +11
    -0
      extra_tests/001_test/main.cpp
  7. +81
    -0
      extra_tests/001_test/syscall.hpp

+ 1
- 1
.gitignore View File

@ -43,4 +43,4 @@ bin/tests.S
bin/tests.S.zip
vgcore.*
doc/*
.vscode/launch.json
.vscode/launch.json

+ 5
- 0
Makefile View File

@ -23,6 +23,11 @@ tests: bin/tests
@llvm-cov report ./bin/tests -instr-profile=./bin/tests.profdata $(EVERY_USEFUL_FILE)
@llvm-cov report ./bin/tests -instr-profile=./bin/tests.profdata $(EVERY_USEFUL_FILE) | tail -n 1 | tr -s " " | sed -e 's/ /,/g' -- | awk -F "," '{print $$9}' | sed -e 's/^/Untested lines: /g'
extras:
@for dir in $(wildcard extra_tests/*/.); do \
$(MAKE) -C $$dir; \
done
bin/tests: tests.cpp $(TEST_OBJECTS) $(EVERY_USEFUL_FILE) ./tests/test_scaffold.h
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -Itests -Iinclude tests.cpp $(TEST_OBJECTS) -o $@

+ 1
- 0
extra_tests/001_test/.gitignore View File

@ -0,0 +1 @@
./bin/*

+ 17
- 0
extra_tests/001_test/Makefile View File

@ -0,0 +1,17 @@
CXX= clang++
CXXFLAGS= --std=c++20 -target x86_64-none-linux-elf -Os -ffreestanding -nostdlib -pedantic \
-Wno-unknown-attributes -fno-omit-frame-pointer -MD -fno-use-cxa-atexit -fno-rtti -I../../include -I.
# -fsanitize=address -fsanitize-blacklist=blacklist.txt
all: tests
tests: bin/tests
# ./bin/tests
bin/tests: main.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) main.cpp -o $@
clean: ./bin
@rm -rf $<

+ 186
- 0
extra_tests/001_test/gp_config.hpp View File

@ -0,0 +1,186 @@
#pragma once
#include <new>
#include <type_traits>
#include <cstddef>
#include <cstdint>
#ifdef GP_TESTS
class static_mapper;
#else
namespace gp {
class c_allocator;
}
#endif
/**
* @brief This namespace contains the configuration.
*
* This namespace is expected to be fully defined in an include accessible from the root
* of your header list:
* \code{.cpp}
* #include "gp_config.hpp"
* \endcode
*
* The code line above should always be the one including that config and that namespace.
*/
namespace gp_config{
namespace rendering {
/**
* @brief The default type used for rendering processes
*/
using default_type = float;
/**
* @brief The small enough value used in signed distance function resolution
*/
constexpr default_type epsilon = 0.01;
/**
* @brief The default color type
*/
#define GP_CONFIG__RENDERING__COLOR_T vec4
}
/**
* @brief This namespace contains artificial limitations put on the runtime
*/
namespace limits {
/**
* @brief the total number of processes the system is allowed to have
*/
constexpr size_t max_processes = 4096;
/**
* @brief the maximum size a channel can address
*/
constexpr size_t channel_max_size = 1 << 20;
/**
* @brief the default size a channel will take
*/
constexpr size_t channel_default_size = 1 << 16;
/**
* @brief the number of open files each process is allowed to have
*/
constexpr size_t max_fd_per_process = 128;
/**
* @brief the stack size for the new stacks generated by the concurrency system
*/
constexpr size_t process_stack = 1024;
/**
* @brief expected stack alignment
*/
constexpr size_t process_stack_align_to = 16;
/**
* @brief presents the direction of stack growth
*/
constexpr size_t stack_grow_upwards = false;
#if __cpp_lib_hardware_interference_size >= 201603
constexpr size_t hardware_constructive_interference_size = std::hardware_constructive_interference_size;
constexpr size_t hardware_destructive_interference_size = std::hardware_destructive_interference_size;
#else
constexpr size_t hardware_constructive_interference_size = 128;
constexpr size_t hardware_destructive_interference_size = 128;
#endif
constexpr size_t loggers_segment_size = 128;
}
namespace memory_module{
constexpr bool is_ok = true;
constexpr bool prefer_constant_memory = true;
}
typedef uint32_t file_descriptor_t;
/**
* @brief set to true to enable exceptions
*/
constexpr bool has_exceptions = false;
/**
* @brief set to true to activate bounds checking
*/
constexpr bool has_buffer_bounds = true;
//
//
//
/**
* @brief A value used to determine the strength used by random number generators
*
* Value of 8 is considered not cryptographically secure
* Value of 12 offers a good compromise of performance and robustness
* Value of 20 offers maximum robustness
*/
constexpr size_t arc4random_strength = 20;
/**
* @brief an exception that represents an assertion failure
*/
struct assert_failure{
assert_failure(const char* reason)
: what_str{reason}
{}
const char* what_str;
const char* what() {return what_str;}
};
/**
* @brief UNUSED
*/
constexpr size_t assert_buffer_size = 0;
/**
* @brief an assertion function
*/
constexpr auto assertion = [](bool pred, const char* reason) -> void{
if(!pred) {
//log_failure(reason);
if constexpr (has_exceptions)
throw assert_failure(reason);
}
};
enum class cbor_tag {
datetime = 0,
unix_time = 1,
ubignum = 2,
nbignum = 3,
decimal = 4,
bigfloat = 5,
cose_encrypt0 = 16,
cose_mac0 = 17,
cose_sign1 = 18,
expected_base64url = 21,
expected_base64 = 22,
expected_base16 = 23,
encoded_cbor = 24,
url = 32,
base64url = 33,
base64 = 34,
regexp = 35,
mime = 36,
cose_encrypt = 96,
cose_mac = 97,
cose_sign = 98,
signature = 55799
};
}
/**
* @brief a list of error codes
*/
enum class gp_errorcodes : int {
/**
* @brief this error code is activated upon reaching a skipstone limit that seems like infinity.
*/
infinite_skipstone = 3000
};

+ 11
- 0
extra_tests/001_test/main.cpp View File

@ -0,0 +1,11 @@
#include <gp/containers/array.hpp>
#include "syscall.hpp"
gp::buffer<char> hello = "Hello world\n";
extern "C" {
void _start() {
write(1, hello);
exit(0);
}
}

+ 81
- 0
extra_tests/001_test/syscall.hpp View File

@ -0,0 +1,81 @@
#pragma once
#include <cstdint>
#include <cstddef>
#include <gp/containers/buffer.hpp>
template<int64_t syscall_id, int arg_count>
struct syscall;
template<int64_t syscall_id>
struct syscall<syscall_id, 1> {
int64_t operator()(int64_t p1) const {
int64_t ret;
asm volatile
(
"syscall"
: "=a" (ret)
: "0"(syscall_id), "D"(p1)
: "rcx", "r11", "memory"
);
return ret;
}
};
template<int64_t syscall_id>
struct syscall<syscall_id, 2> {
int64_t operator()(int64_t p1,int64_t p2) const {
int64_t ret;
asm volatile
(
"syscall"
: "=a" (ret)
: "0"(syscall_id), "D"(p1), "S"(p2)
: "rcx", "r11", "memory"
);
return ret;
}
};
template<int64_t syscall_id>
struct syscall<syscall_id, 3> {
int64_t operator()(int64_t p1,int64_t p2,int64_t p3) const {
int64_t ret;
asm volatile
(
"syscall"
: "=a" (ret)
: "0"(syscall_id), "D"(p1), "S"(p2), "d"(p3)
: "rcx", "r11", "memory"
);
return ret;
}
};
constexpr auto _read = syscall<0, 3>{};
constexpr auto _write = syscall<1, 3>{};
constexpr auto _exit = syscall<60, 1>{};
inline int read(int fd, char* buffer, size_t sz) {
return _read((int64_t)fd, (int64_t)buffer, (int64_t)sz);
}
inline int write(int fd, char* buffer, size_t sz) {
return _write((int64_t)fd, (int64_t)buffer, (int64_t)sz);
}
inline int read(int fd, gp::buffer<char> buffer) {
return _read((int64_t)fd, (int64_t)buffer.begin().data, (int64_t)buffer.size());
}
inline int write(int fd, gp::buffer<char> buffer) {
return _write((int64_t)fd, (int64_t)buffer.begin().data, (int64_t)buffer.size());
}
extern "C" {
inline __attribute__ ((__noreturn__)) void exit(int status) {
_exit((int64_t)status);
while(true);
}
}

Loading…
Cancel
Save