diff --git a/.gitignore b/.gitignore index f4f9745..b829a71 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ *.app bin/tests +default.profraw +bin/tests.profdata +bin/tests.profraw diff --git a/Makefile b/Makefile index 50b71df..397d6e7 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,17 @@ -CXX= clang++ -CXXFLAGS= --std=c++2a +CXX= clang++-8 +CXXFLAGS= --std=c++17 -fprofile-instr-generate -fcoverage-mapping all: tests tests: bin/tests - ./bin/tests + LLVM_PROFILE_FILE="./bin/tests.profraw" ./bin/tests + @llvm-profdata merge -sparse ./bin/tests.profraw -o ./bin/tests.profdata + @llvm-cov report ./bin/tests -instr-profile=./bin/tests.profdata $(wildcard ./tests/*.cpp) include/*.hpp + @llvm-cov report ./bin/tests -instr-profile=./bin/tests.profdata $(wildcard ./tests/*.cpp) include/*.hpp | tail -n 1 | tr -s "\t" | awk '{print "$8" }' -bin/tests: tests.cpp $(wildcard tests/*.cpp) +bin/tests: tests.cpp $(wildcard tests/*.cpp) ./tests/test_scaffold.h @mkdir -p $(@D) - $(CXX) $(CXXFLAGS) -Itests -Iinclude tests.cpp -o $@ \ No newline at end of file + $(CXX) $(CXXFLAGS) -Itests -Iinclude tests.cpp -o $@ + +clean: ./bin + @rm -rf $< \ No newline at end of file diff --git a/include/shared_fd.hpp b/include/shared_fd.hpp index 3f59c93..b55f6a3 100644 --- a/include/shared_fd.hpp +++ b/include/shared_fd.hpp @@ -1,2 +1,56 @@ #pragma once +#include +#include +#include +#include +#include +namespace gp{ + using open_opt_flags = int; + + enum class open_options : open_opt_flags { + append = O_APPEND, + create = O_CREAT, + async = O_ASYNC, + direct = O_DIRECT, + data_sync = O_DSYNC, + file_sync = O_SYNC, + exclusive = O_EXCL, + no_access_time = O_NOATIME, + no_follow = O_NOFOLLOW, +#ifdef O_TEMP + temporary = O_TEMP, +#endif +#ifdef O_TRUC + truncate = O_TRUC, +#endif + }; + + using open_opt_mode = int; + + enum class open_modes : open_opt_mode { + user_read = S_IRUSR, + user_write = S_IWUSR, + user_exec = S_IXUSR, + group_read = S_IRGRP, + group_write = S_IWGRP, + group_exec = S_IXGRP, + other_read = S_IROTH, + other_write = S_IWOTH, + other_exec = S_IXOTH, + set_uid = S_ISUID, + set_gid = S_ISGID, + sticky_bit = S_ISVTX, + }; + + class shared_fd { + const int fd; + shared_fd(int fd_v) + : fd(fd_v) {} + + public: + static shared_fd open(const std::string& filename, const open_opt_flags& flags) { + + } + }; +} \ No newline at end of file diff --git a/tests.cpp b/tests.cpp index 91b3af1..b342b0c 100644 --- a/tests.cpp +++ b/tests.cpp @@ -1,4 +1,4 @@ -#include "test_scaffold.cpp" +#include "test_scaffold.h" #include "meta_test.cpp" #include diff --git a/tests/meta_test.cpp b/tests/meta_test.cpp index a93b928..0c6155d 100644 --- a/tests/meta_test.cpp +++ b/tests/meta_test.cpp @@ -1,4 +1,4 @@ -#include "test_scaffold.cpp" +#include "test_scaffold.h" struct meta_test : public test_scaffold { meta_test() { diff --git a/tests/test_scaffold.cpp b/tests/test_scaffold.h similarity index 100% rename from tests/test_scaffold.cpp rename to tests/test_scaffold.h