70 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C++
		
	
	
	
//===- lld/unittest/WinLinkDriverTest.cpp ---------------------------------===//
 | 
						|
//
 | 
						|
//                     The LLVM Compiler Infrastructure
 | 
						|
//
 | 
						|
// This file is distributed under the University of Illinois Open Source
 | 
						|
// License. See LICENSE.TXT for details.
 | 
						|
//
 | 
						|
//===----------------------------------------------------------------------===//
 | 
						|
///
 | 
						|
/// \file
 | 
						|
/// \brief Windows link.exe driver tests.
 | 
						|
///
 | 
						|
//===----------------------------------------------------------------------===//
 | 
						|
 | 
						|
#include "DriverTest.h"
 | 
						|
 | 
						|
#include "lld/ReaderWriter/PECOFFTargetInfo.h"
 | 
						|
#include "llvm/Support/COFF.h"
 | 
						|
 | 
						|
using namespace llvm;
 | 
						|
using namespace lld;
 | 
						|
 | 
						|
namespace {
 | 
						|
 | 
						|
class WinLinkParserTest : public ParserTest<WinLinkDriver, PECOFFTargetInfo> {
 | 
						|
protected:
 | 
						|
  virtual PECOFFTargetInfo *doParse(int argc, const char **argv,
 | 
						|
                                    raw_ostream &diag) {
 | 
						|
    PECOFFTargetInfo *info = new PECOFFTargetInfo();
 | 
						|
    EXPECT_FALSE(WinLinkDriver::parse(argc, argv, *info, diag));
 | 
						|
    return info;
 | 
						|
  }
 | 
						|
};
 | 
						|
 | 
						|
TEST_F(WinLinkParserTest, Basic) {
 | 
						|
  parse("link.exe", "-subsystem", "console", "-out", "a.exe",
 | 
						|
        "a.obj", "b.obj", "c.obj", nullptr);
 | 
						|
  EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, info->getSubsystem());
 | 
						|
  EXPECT_EQ("a.exe", info->outputPath());
 | 
						|
  EXPECT_EQ(3, (int)inputFiles.size());
 | 
						|
  EXPECT_EQ("a.obj", inputFiles[0]);
 | 
						|
  EXPECT_EQ("b.obj", inputFiles[1]);
 | 
						|
  EXPECT_EQ("c.obj", inputFiles[2]);
 | 
						|
}
 | 
						|
 | 
						|
TEST_F(WinLinkParserTest, WindowsStyleOption) {
 | 
						|
  parse("link.exe", "/subsystem:console", "/out:a.exe", "a.obj", nullptr);
 | 
						|
  EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, info->getSubsystem());
 | 
						|
  EXPECT_EQ("a.exe", info->outputPath());
 | 
						|
  EXPECT_EQ(1, (int)inputFiles.size());
 | 
						|
  EXPECT_EQ("a.obj", inputFiles[0]);
 | 
						|
}
 | 
						|
 | 
						|
TEST_F(WinLinkParserTest, NoFileExtension) {
 | 
						|
  parse("link.exe", "foo", "bar", nullptr);
 | 
						|
  EXPECT_EQ("foo.exe", info->outputPath());
 | 
						|
  EXPECT_EQ(2, (int)inputFiles.size());
 | 
						|
  EXPECT_EQ("foo.obj", inputFiles[0]);
 | 
						|
  EXPECT_EQ("bar.obj", inputFiles[1]);
 | 
						|
}
 | 
						|
 | 
						|
TEST_F(WinLinkParserTest, NonStandardFileExtension) {
 | 
						|
  parse("link.exe", "foo.o", nullptr);
 | 
						|
  EXPECT_EQ("foo.exe", info->outputPath());
 | 
						|
  EXPECT_EQ(1, (int)inputFiles.size());
 | 
						|
  EXPECT_EQ("foo.o", inputFiles[0]);
 | 
						|
}
 | 
						|
 | 
						|
}  // end anonymous namespace
 |