diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-03-28 22:27:01 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-03-28 22:27:01 +0100 |
commit | ee18ec019ef6f0ef9d7cd3b4cf0314291814cab0 (patch) | |
tree | 5f23e0bce52e24c3c04825ad008ec74a5e722a1c /test-elf.cpp | |
parent | 7fdcbd50a35c17e8ea7d88fbcaa3080ee44351b3 (diff) |
Add ELF handling (WIP)
Diffstat (limited to 'test-elf.cpp')
-rw-r--r-- | test-elf.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test-elf.cpp b/test-elf.cpp index d1aebd3..dba220e 100644 --- a/test-elf.cpp +++ b/test-elf.cpp @@ -12,10 +12,12 @@ #include <map> #include <memory> #include <string> +#include <system_error> #include <utility> #include <vector> using namespace std::string_literals; +namespace fs = std::filesystem; class ElfTest: public ::testing::Test { @@ -25,10 +27,32 @@ protected: } ~ElfTest() { } + fs::path TempFilename(){return "tempfile.txt";} + + void SetUp(){ + std::error_code ec; + fs::remove(TempFilename(), ec); + } + void TearDown(){ + std::error_code ec; + //fs::remove(TempFilename(), ec); + } }; +#if 0 TEST_F(ElfTest, read) { } +#endif TEST_F(ElfTest, write) { + Elf::Write(TempFilename(), + { + 0x48, 0xc7, 0xc0, 0x3c, 0x00, 0x00, 0x00, // mov $0x3c,%rax # syscall 60 + 0x48, 0x31, 0xff, // xor %rdi,%rdi # exit code 0 + 0x0f, 0x05 // syscall + }); + + ASSERT_TRUE(fs::exists(TempFilename())); + ASSERT_GT(fs::file_size(TempFilename()), 0); } + |