This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] gold: use open_descriptor in binary_unittest
- From: Roland McGrath <mcgrathr at google dot com>
- To: binutils at sourceware dot org
- Date: Fri, 7 Dec 2012 13:36:55 -0800
- Subject: [PATCH] gold: use open_descriptor in binary_unittest
gold's binary_unittest fails on a system where O_BINARY is meaningful.
Rather than just copy the knowledge of O_BINARY setting into the test code,
I made it use open_descriptor like everything else does.
Ok for trunk and 2.23?
Thanks,
Roland
gold/
2012-12-07 Roland McGrath <mcgrathr@google.com>
* testsuite/binary_unittest.cc (Sized_binary_test):
Use open_descriptor rather than ::open.
--- a/gold/testsuite/binary_unittest.cc
+++ b/gold/testsuite/binary_unittest.cc
@@ -1,6 +1,6 @@
// binary_unittest.cc -- test Binary_to_elf
-// Copyright 2008 Free Software Foundation, Inc.
+// Copyright 2008, 2012 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@ -33,6 +33,7 @@
#include "options.h"
#include "binary.h"
#include "object.h"
+#include "descriptors.h"
#include "test.h"
#include "testfile.h"
@@ -53,7 +54,7 @@ Sized_binary_test()
// Use the executable itself as the binary data.
struct stat st;
CHECK(::stat(gold::program_name, &st) == 0);
- int o = ::open(gold::program_name, O_RDONLY);
+ int o = open_descriptor(-1, gold::program_name, O_RDONLY);
CHECK(o >= 0);
unsigned char* filedata = new unsigned char[st.st_size];
CHECK(::read(o, filedata, st.st_size) == st.st_size);