You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
projects
resources
runtimes
scripts
test
tools
unittests
ADT
APFloatTest.cpp.REMOVED.git-id
APIntTest.cpp
APSIntTest.cpp
ArrayRefTest.cpp
BitVectorTest.cpp
BitmaskEnumTest.cpp
BreadthFirstIteratorTest.cpp
BumpPtrListTest.cpp
CMakeLists.txt
DAGDeltaAlgorithmTest.cpp
DeltaAlgorithmTest.cpp
DenseMapTest.cpp
DenseSetTest.cpp
DepthFirstIteratorTest.cpp
EquivalenceClassesTest.cpp
FoldingSet.cpp
FunctionRefTest.cpp
HashingTest.cpp
IListBaseTest.cpp
IListIteratorTest.cpp
IListNodeBaseTest.cpp
IListNodeTest.cpp
IListSentinelTest.cpp
IListTest.cpp
ImmutableMapTest.cpp
ImmutableSetTest.cpp
IntEqClassesTest.cpp
IntervalMapTest.cpp
IntrusiveRefCntPtrTest.cpp
IteratorTest.cpp
MakeUniqueTest.cpp
MapVectorTest.cpp
MappedIteratorTest.cpp
OptionalTest.cpp
PackedVectorTest.cpp
PointerEmbeddedIntTest.cpp
PointerIntPairTest.cpp
PointerSumTypeTest.cpp
PointerUnionTest.cpp
PostOrderIteratorTest.cpp
PriorityWorklistTest.cpp
RangeAdapterTest.cpp
SCCIteratorTest.cpp
STLExtrasTest.cpp
ScopeExitTest.cpp
SequenceTest.cpp
SetVectorTest.cpp
SimpleIListTest.cpp
SmallPtrSetTest.cpp
SmallStringTest.cpp
SmallVectorTest.cpp
SparseBitVectorTest.cpp
SparseMultiSetTest.cpp
SparseSetTest.cpp
StringExtrasTest.cpp
StringMapTest.cpp
StringRefTest.cpp
StringSwitchTest.cpp
TestGraph.h
TinyPtrVectorTest.cpp
TripleTest.cpp
TwineTest.cpp
VariadicFunctionTest.cpp
Analysis
AsmParser
BinaryFormat
Bitcode
CodeGen
DebugInfo
ExecutionEngine
FuzzMutate
IR
LineEditor
Linker
MC
MI
Object
ObjectYAML
Option
ProfileData
Support
Target
Transforms
XRay
tools
CMakeLists.txt
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
version.txt.in
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
106 lines
2.7 KiB
C++
106 lines
2.7 KiB
C++
//===- llvm/unittest/ADT/DAGDeltaAlgorithmTest.cpp ------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ADT/DAGDeltaAlgorithm.h"
|
|
#include "gtest/gtest.h"
|
|
#include <algorithm>
|
|
#include <cstdarg>
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
typedef DAGDeltaAlgorithm::edge_ty edge_ty;
|
|
|
|
class FixedDAGDeltaAlgorithm : public DAGDeltaAlgorithm {
|
|
changeset_ty FailingSet;
|
|
unsigned NumTests;
|
|
|
|
protected:
|
|
bool ExecuteOneTest(const changeset_ty &Changes) override {
|
|
++NumTests;
|
|
return std::includes(Changes.begin(), Changes.end(),
|
|
FailingSet.begin(), FailingSet.end());
|
|
}
|
|
|
|
public:
|
|
FixedDAGDeltaAlgorithm(const changeset_ty &_FailingSet)
|
|
: FailingSet(_FailingSet),
|
|
NumTests(0) {}
|
|
|
|
unsigned getNumTests() const { return NumTests; }
|
|
};
|
|
|
|
std::set<unsigned> fixed_set(unsigned N, ...) {
|
|
std::set<unsigned> S;
|
|
va_list ap;
|
|
va_start(ap, N);
|
|
for (unsigned i = 0; i != N; ++i)
|
|
S.insert(va_arg(ap, unsigned));
|
|
va_end(ap);
|
|
return S;
|
|
}
|
|
|
|
std::set<unsigned> range(unsigned Start, unsigned End) {
|
|
std::set<unsigned> S;
|
|
while (Start != End)
|
|
S.insert(Start++);
|
|
return S;
|
|
}
|
|
|
|
std::set<unsigned> range(unsigned N) {
|
|
return range(0, N);
|
|
}
|
|
|
|
TEST(DAGDeltaAlgorithmTest, Basic) {
|
|
std::vector<edge_ty> Deps;
|
|
|
|
// Dependencies:
|
|
// 1 - 3
|
|
Deps.clear();
|
|
Deps.push_back(std::make_pair(3, 1));
|
|
|
|
// P = {3,5,7} \in S,
|
|
// [0, 20),
|
|
// should minimize to {1,3,5,7} in a reasonable number of tests.
|
|
FixedDAGDeltaAlgorithm FDA(fixed_set(3, 3, 5, 7));
|
|
EXPECT_EQ(fixed_set(4, 1, 3, 5, 7), FDA.Run(range(20), Deps));
|
|
EXPECT_GE(46U, FDA.getNumTests());
|
|
|
|
// Dependencies:
|
|
// 0 - 1
|
|
// \- 2 - 3
|
|
// \- 4
|
|
Deps.clear();
|
|
Deps.push_back(std::make_pair(1, 0));
|
|
Deps.push_back(std::make_pair(2, 0));
|
|
Deps.push_back(std::make_pair(4, 0));
|
|
Deps.push_back(std::make_pair(3, 2));
|
|
|
|
// This is a case where we must hold required changes.
|
|
//
|
|
// P = {1,3} \in S,
|
|
// [0, 5),
|
|
// should minimize to {0,1,2,3} in a small number of tests.
|
|
FixedDAGDeltaAlgorithm FDA2(fixed_set(2, 1, 3));
|
|
EXPECT_EQ(fixed_set(4, 0, 1, 2, 3), FDA2.Run(range(5), Deps));
|
|
EXPECT_GE(9U, FDA2.getNumTests());
|
|
|
|
// This is a case where we should quickly prune part of the tree.
|
|
//
|
|
// P = {4} \in S,
|
|
// [0, 5),
|
|
// should minimize to {0,4} in a small number of tests.
|
|
FixedDAGDeltaAlgorithm FDA3(fixed_set(1, 4));
|
|
EXPECT_EQ(fixed_set(2, 0, 4), FDA3.Run(range(5), Deps));
|
|
EXPECT_GE(6U, FDA3.getNumTests());
|
|
}
|
|
|
|
}
|
|
|