Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3034)

Unified Diff: courgette/encode_decode_unittest.cc

Issue 8477045: Add Elf 32 Support to Courgette. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Remove debug printf present by mistake. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/disassembler_win32_x86.cc ('k') | courgette/encoded_program.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/encode_decode_unittest.cc
diff --git a/courgette/encode_decode_unittest.cc b/courgette/encode_decode_unittest.cc
index 90f5cd6b4da2633d6f6363926b0c860c1d8247c1..20f0e168448a384d46404d059b54abe1b6063a0f 100644
--- a/courgette/encode_decode_unittest.cc
+++ b/courgette/encode_decode_unittest.cc
@@ -8,20 +8,20 @@
class EncodeDecodeTest : public BaseTest {
public:
- void TestExe(const char *) const;
+ void TestAssembleToStreamDisassemble(std::string file,
+ size_t expected_encoded_lenth) const;
};
-void EncodeDecodeTest::TestExe(const char* file_name) const {
- // Test top-level Courgette API for converting an a file to a binary
- // assembly representation and back.
- std::string file1 = FileContents(file_name);
-
- const void* original_buffer = file1.c_str();
- size_t original_length = file1.size();
+void EncodeDecodeTest::TestAssembleToStreamDisassemble(
+ std::string file,
+ size_t expected_encoded_lenth) const {
+ const void* original_buffer = file.c_str();
+ size_t original_length = file.length();
courgette::AssemblyProgram* program = NULL;
const courgette::Status parse_status =
- courgette::ParseDetectedExecutable(original_buffer, original_length,
+ courgette::ParseDetectedExecutable(original_buffer,
+ original_length,
&program);
EXPECT_EQ(courgette::C_OK, parse_status);
@@ -45,7 +45,7 @@ void EncodeDecodeTest::TestExe(const char* file_name) const {
const void* buffer = sink.Buffer();
size_t length = sink.Length();
- EXPECT_EQ(971850U, length);
+ EXPECT_EQ(expected_encoded_lenth, length);
courgette::SourceStreamSet sources;
bool can_get_source_streams = sources.Init(buffer, length);
@@ -68,7 +68,12 @@ void EncodeDecodeTest::TestExe(const char* file_name) const {
DeleteEncodedProgram(encoded2);
}
+TEST_F(EncodeDecodeTest, PE) {
+ std::string file = FileContents("setup1.exe");
+ TestAssembleToStreamDisassemble(file, 971850);
+}
-TEST_F(EncodeDecodeTest, All) {
- TestExe("setup1.exe");
+TEST_F(EncodeDecodeTest, Elf_Small) {
+ std::string file = FileContents("elf-32-1");
+ TestAssembleToStreamDisassemble(file, 135988);
}
« no previous file with comments | « courgette/disassembler_win32_x86.cc ('k') | courgette/encoded_program.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698