diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-10-24 16:32:18 +0200 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-10-24 16:32:18 +0200 |
commit | 1011655d2ef76a0c0aa29dbbff091dab139198e3 (patch) | |
tree | 63763828f259846f56285691805c187583ecb6bb /test-elf.cpp | |
parent | 1349c00b782eca3ea841bfa388301cb6fc908cc7 (diff) |
Add FlowGraph
Diffstat (limited to 'test-elf.cpp')
-rw-r--r-- | test-elf.cpp | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/test-elf.cpp b/test-elf.cpp deleted file mode 100644 index 0bf1d42..0000000 --- a/test-elf.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "elf.h" -#include "minicc.h" - -#include <boost/algorithm/string.hpp> - -#include "gmock/gmock.h" -#include "gtest/gtest.h" - -#include <algorithm> -#include <cctype> -#include <deque> -#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 -{ -protected: - ElfTest() { - //debug = true; - } - ~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_code) { - 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); -} - -TEST_F(ElfTest, write_code_data) { - Elf::Write(TempFilename(), - { - 0x48, 0xc7, 0xc0, 0x3c, 0x00, 0x00, 0x00, // mov $0x3c,%rax # syscall 60 - 0x48, 0x8b, 0x3c, 0x25, 0x00, 0x20, 0x40, // mov 0x402000,%rdi # use value from data segment as exit code - 0, - 0x0f, 0x05, // syscall - }, - {1, 0, 0, 0, 0, 0, 0, 0}); - - ASSERT_TRUE(fs::exists(TempFilename())); - ASSERT_GT(fs::file_size(TempFilename()), 0); -} |