Browse Source

Added more scaffolding (tests final)t

devel
Ludovic 'Archivist' Lagouardette 4 years ago
parent
commit
5d787ad006
6 changed files with 70 additions and 7 deletions
  1. +3
    -0
      .gitignore
  2. +11
    -5
      Makefile
  3. +54
    -0
      include/shared_fd.hpp
  4. +1
    -1
      tests.cpp
  5. +1
    -1
      tests/meta_test.cpp
  6. +0
    -0
      tests/test_scaffold.h

+ 3
- 0
.gitignore View File

@ -33,3 +33,6 @@
*.app
bin/tests
default.profraw
bin/tests.profdata
bin/tests.profraw

+ 11
- 5
Makefile View File

@ -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 $@
$(CXX) $(CXXFLAGS) -Itests -Iinclude tests.cpp -o $@
clean: ./bin
@rm -rf $<

+ 54
- 0
include/shared_fd.hpp View File

@ -1,2 +1,56 @@
#pragma once
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string>
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) {
}
};
}

+ 1
- 1
tests.cpp View File

@ -1,4 +1,4 @@
#include "test_scaffold.cpp"
#include "test_scaffold.h"
#include "meta_test.cpp"
#include <iostream>

+ 1
- 1
tests/meta_test.cpp View File

@ -1,4 +1,4 @@
#include "test_scaffold.cpp"
#include "test_scaffold.h"
struct meta_test : public test_scaffold {
meta_test() {

tests/test_scaffold.cpp → tests/test_scaffold.h View File


Loading…
Cancel
Save