|
|
|
@ -37,13 +37,9 @@ using CommandList = CalamaresUtils::CommandList;
|
|
|
|
|
using std::operator""s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShellProcessTests::ShellProcessTests()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
ShellProcessTests::ShellProcessTests() {}
|
|
|
|
|
|
|
|
|
|
ShellProcessTests::~ShellProcessTests()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
ShellProcessTests::~ShellProcessTests() {}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ShellProcessTests::initTestCase()
|
|
|
|
@ -66,8 +62,7 @@ ShellProcessTests::testProcessListSampleConfig()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandList cl(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
QVERIFY( !cl.isEmpty() );
|
|
|
|
|
QCOMPARE( cl.count(), 3 );
|
|
|
|
|
|
|
|
|
@ -75,7 +70,8 @@ ShellProcessTests::testProcessListSampleConfig()
|
|
|
|
|
QCOMPARE( cl.at( 2 ).timeout(), 3600s ); // slowloris
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellProcessTests::testProcessListFromList()
|
|
|
|
|
void
|
|
|
|
|
ShellProcessTests::testProcessListFromList()
|
|
|
|
|
{
|
|
|
|
|
YAML::Node doc = YAML::Load( R"(---
|
|
|
|
|
script:
|
|
|
|
@ -83,8 +79,7 @@ script:
|
|
|
|
|
- "ls /nonexistent"
|
|
|
|
|
- "/bin/false"
|
|
|
|
|
)" );
|
|
|
|
|
CommandList cl(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
QVERIFY( !cl.isEmpty() );
|
|
|
|
|
QCOMPARE( cl.count(), 3 );
|
|
|
|
|
|
|
|
|
@ -95,19 +90,18 @@ script:
|
|
|
|
|
- false
|
|
|
|
|
- "ls /nonexistent"
|
|
|
|
|
)" );
|
|
|
|
|
CommandList cl1(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
QVERIFY( !cl1.isEmpty() );
|
|
|
|
|
QCOMPARE( cl1.count(), 2 ); // One element ignored
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellProcessTests::testProcessListFromString()
|
|
|
|
|
void
|
|
|
|
|
ShellProcessTests::testProcessListFromString()
|
|
|
|
|
{
|
|
|
|
|
YAML::Node doc = YAML::Load( R"(---
|
|
|
|
|
script: "ls /tmp"
|
|
|
|
|
)" );
|
|
|
|
|
CommandList cl(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
|
|
|
|
|
QVERIFY( !cl.isEmpty() );
|
|
|
|
|
QCOMPARE( cl.count(), 1 );
|
|
|
|
@ -118,21 +112,20 @@ script: "ls /tmp"
|
|
|
|
|
doc = YAML::Load( R"(---
|
|
|
|
|
script: false
|
|
|
|
|
)" );
|
|
|
|
|
CommandList cl1(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
QVERIFY( cl1.isEmpty() );
|
|
|
|
|
QCOMPARE( cl1.count(), 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellProcessTests::testProcessFromObject()
|
|
|
|
|
void
|
|
|
|
|
ShellProcessTests::testProcessFromObject()
|
|
|
|
|
{
|
|
|
|
|
YAML::Node doc = YAML::Load( R"(---
|
|
|
|
|
script:
|
|
|
|
|
command: "ls /tmp"
|
|
|
|
|
timeout: 20
|
|
|
|
|
)" );
|
|
|
|
|
CommandList cl(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
|
|
|
|
|
QVERIFY( !cl.isEmpty() );
|
|
|
|
|
QCOMPARE( cl.count(), 1 );
|
|
|
|
@ -140,7 +133,8 @@ script:
|
|
|
|
|
QCOMPARE( cl.at( 0 ).command(), QStringLiteral( "ls /tmp" ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellProcessTests::testProcessListFromObject()
|
|
|
|
|
void
|
|
|
|
|
ShellProcessTests::testProcessListFromObject()
|
|
|
|
|
{
|
|
|
|
|
YAML::Node doc = YAML::Load( R"(---
|
|
|
|
|
script:
|
|
|
|
@ -148,8 +142,7 @@ script:
|
|
|
|
|
timeout: 12
|
|
|
|
|
- "-/bin/false"
|
|
|
|
|
)" );
|
|
|
|
|
CommandList cl(
|
|
|
|
|
CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
|
|
|
|
QVERIFY( !cl.isEmpty() );
|
|
|
|
|
QCOMPARE( cl.count(), 2 );
|
|
|
|
|
QCOMPARE( cl.at( 0 ).timeout(), 12s );
|
|
|
|
@ -157,25 +150,28 @@ script:
|
|
|
|
|
QCOMPARE( cl.at( 1 ).timeout(), CalamaresUtils::CommandLine::TimeoutNotSet() ); // not set
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShellProcessTests::testRootSubstitution()
|
|
|
|
|
void
|
|
|
|
|
ShellProcessTests::testRootSubstitution()
|
|
|
|
|
{
|
|
|
|
|
YAML::Node doc = YAML::Load( R"(---
|
|
|
|
|
script:
|
|
|
|
|
- "ls /tmp"
|
|
|
|
|
)" );
|
|
|
|
|
QVariant plainScript = CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" );
|
|
|
|
|
QVariant rootScript = CalamaresUtils::yamlMapToVariant(
|
|
|
|
|
YAML::Load( R"(---
|
|
|
|
|
QVariant rootScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(---
|
|
|
|
|
script:
|
|
|
|
|
- "ls @@ROOT@@"
|
|
|
|
|
)" ) ).toMap().value( "script" );
|
|
|
|
|
QVariant userScript = CalamaresUtils::yamlMapToVariant(
|
|
|
|
|
YAML::Load( R"(---
|
|
|
|
|
)" ) )
|
|
|
|
|
.toMap()
|
|
|
|
|
.value( "script" );
|
|
|
|
|
QVariant userScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(---
|
|
|
|
|
script:
|
|
|
|
|
- mktemp -d @@ROOT@@/calatestXXXXXXXX
|
|
|
|
|
- "chown @@USER@@ @@ROOT@@/calatest*"
|
|
|
|
|
- rm -rf @@ROOT@@/calatest*
|
|
|
|
|
)" ) ).toMap().value( "script" );
|
|
|
|
|
)" ) )
|
|
|
|
|
.toMap()
|
|
|
|
|
.value( "script" );
|
|
|
|
|
|
|
|
|
|
if ( !Calamares::JobQueue::instance() )
|
|
|
|
|
(void)new Calamares::JobQueue( nullptr );
|
|
|
|
|