-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test interaction between SVS enable and substates
See #475.
- Loading branch information
1 parent
c556fcb
commit 3d0d4ba
Showing
4 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#include "SvsTests.hpp" | ||
#include "soar_instance.h" | ||
|
||
void SvsTests::setUp() | ||
{ | ||
kernel = sml::Kernel::CreateKernelInCurrentThread(true, sml::Kernel::kUseAnyPort); | ||
configure_for_unit_tests(); | ||
agent = kernel->CreateAgent("soar1"); | ||
configure_agent_for_unit_tests(NULL); | ||
} | ||
|
||
void SvsTests::tearDown(bool caught) | ||
{ | ||
kernel->DestroyAgent(agent); | ||
kernel->Shutdown(); | ||
delete kernel; | ||
kernel = nullptr; | ||
} | ||
|
||
void SvsTests::testEnableFromTopState() | ||
{ | ||
// enable, step, check that ^svs exists everywhere | ||
|
||
agent->ExecuteCommandLine("svs --enable"); | ||
assertTrue_msg("Failed to enable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
agent->ExecuteCommandLine("svs --enable-in-substates"); | ||
assertTrue_msg("Failed to enable SVS in substates.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
std::string result = agent->ExecuteCommandLine("print S1"); | ||
assertFalse_msg("Expected to find ^svs in S1; return was " + result, | ||
result.find("^svs") == std::string::npos); | ||
|
||
// no productions, so agent will subgoal each step | ||
agent->ExecuteCommandLine("step 2"); | ||
|
||
result = agent->ExecuteCommandLine("print S2"); | ||
assertFalse_msg("Expected to find ^svs in S2; return was: " + result, | ||
result.find("^svs") == std::string::npos); | ||
result = agent->ExecuteCommandLine("print S3"); | ||
assertFalse_msg("Expected to find ^svs in S3", | ||
result.find("^svs") == std::string::npos); | ||
} | ||
|
||
void SvsTests::testEnableAndDisableInSubstatesFromTopState() { | ||
// disable-in-substates, step, ^svs should not exist in substates | ||
|
||
agent->ExecuteCommandLine("svs --enable"); | ||
assertTrue_msg("Failed to enable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
agent->ExecuteCommandLine("svs --disable-in-substates"); | ||
assertTrue_msg("Failed to enable SVS in substates.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
std::string result = agent->ExecuteCommandLine("print S1"); | ||
assertFalse_msg("Expected to find ^svs in S1", | ||
result.find("^svs") == std::string::npos); | ||
|
||
// no productions, so agent will subgoal each step | ||
agent->ExecuteCommandLine("step 2"); | ||
|
||
result = agent->ExecuteCommandLine("print S2"); | ||
assertTrue_msg("Expected to not find ^svs in S2; return was: " + result, | ||
result.find("^svs") == std::string::npos); | ||
result = agent->ExecuteCommandLine("print S3"); | ||
assertTrue_msg("Expected to not find ^svs in S3", | ||
result.find("^svs") == std::string::npos); | ||
} | ||
|
||
void SvsTests::testCannotDisableInSubstate() | ||
{ | ||
// enable, step, try to disable, should fail | ||
|
||
agent->ExecuteCommandLine("svs --enable"); | ||
assertTrue_msg("Failed to enable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
// no productions, so agent will subgoal each step | ||
agent->ExecuteCommandLine("step 1"); | ||
|
||
std::string result = agent->ExecuteCommandLine("svs --disable"); | ||
assertFalse_msg("Expected not to be able to disable SVS from a substate; return was: " + result + " (" + (agent->GetLastCommandLineResult() ? "true" : "false") + ")", | ||
agent->GetLastCommandLineResult()); | ||
|
||
result = agent->ExecuteCommandLine("svs --disable-in-substates"); | ||
assertFalse_msg("Expected not to be able to disable SVS in substates from a substate; return was: " + result, | ||
agent->GetLastCommandLineResult()); | ||
} | ||
|
||
void SvsTests::testEnableFromSubstate() | ||
{ | ||
// disable, step, enable, check that ^svs exists in all states | ||
|
||
|
||
|
||
agent->ExecuteCommandLine("svs --disable"); | ||
assertTrue_msg("Failed to disable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
// no productions, so agent will subgoal each step | ||
agent->ExecuteCommandLine("step 2"); | ||
agent->ExecuteCommandLine("svs --enable"); | ||
assertTrue_msg("Failed to enable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
std::string result = agent->ExecuteCommandLine("print S1"); | ||
assertFalse_msg("Expected to find ^svs in S1", | ||
result.find("^svs") == std::string::npos); | ||
result = agent->ExecuteCommandLine("print S2"); | ||
assertFalse_msg("Expected to find ^svs in S2", | ||
result.find("^svs") == std::string::npos); | ||
result = agent->ExecuteCommandLine("print S3"); | ||
assertFalse_msg("Expected to find ^svs in S3", | ||
result.find("^svs") == std::string::npos); | ||
|
||
} | ||
|
||
void SvsTests::testEnableInSubstatesFromSubstate() | ||
{ | ||
// disable-in-substates, step and then enable, check that ^svs exists only on top state | ||
|
||
agent->ExecuteCommandLine("svs --disable"); | ||
assertTrue_msg("Failed to disable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
agent->ExecuteCommandLine("svs --disable-in-substates"); | ||
assertTrue_msg("Failed to disable SVS in substates.", | ||
agent->GetLastCommandLineResult()); | ||
|
||
// no productions, so agent will subgoal each step | ||
agent->ExecuteCommandLine("step 2"); | ||
|
||
std::string result = agent->ExecuteCommandLine("print S1"); | ||
assertTrue_msg("Expected to not find ^svs in S1; return was " + result, | ||
result.find("^svs") == std::string::npos); | ||
result = agent->ExecuteCommandLine("print S3"); | ||
assertTrue_msg("Expected to not find ^svs in S3", | ||
result.find("^svs") == std::string::npos); | ||
|
||
agent->ExecuteCommandLine("svs --enable"); | ||
assertTrue_msg("Failed to enable SVS.", | ||
agent->GetLastCommandLineResult()); | ||
result = agent->ExecuteCommandLine("print S3"); | ||
assertTrue_msg("Expected to not find ^svs in S3", | ||
result.find("^svs") == std::string::npos); | ||
|
||
// then enable-in-substates and check that ^svs exists on all states | ||
|
||
agent->ExecuteCommandLine("svs --enable-in-substates"); | ||
assertTrue_msg("Failed to enable SVS in substates.", | ||
agent->GetLastCommandLineResult()); | ||
result = agent->ExecuteCommandLine("print S3"); | ||
assertFalse_msg("Expected to find ^svs in S3", | ||
result.find("^svs") == std::string::npos); | ||
} | ||
|
||
void SvsTests::testSubstateWhenDisabledInSubstates() | ||
{ | ||
// TODO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// SvsTests.hpp | ||
// Soar-xcode | ||
// | ||
// Created by Alex Turner on 6/27/15. | ||
// Copyright © 2015 University of Michigan – Soar Group. All rights reserved. | ||
// | ||
|
||
#ifndef SvsTests_cpp | ||
#define SvsTests_cpp | ||
|
||
#include "portability.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <sstream> | ||
|
||
#include "sml_Connection.h" | ||
#include "sml_Client.h" | ||
#include "sml_Utils.h" | ||
#include "thread_Event.h" | ||
#include "sml_Names.h" | ||
|
||
#include "FunctionalTestHarness.hpp" | ||
|
||
class SvsTests : public FunctionalTestHarness | ||
{ | ||
private: | ||
sml::Agent* agent; | ||
sml::Kernel* kernel; | ||
|
||
public: | ||
TEST_CATEGORY(SvsTests); | ||
void before() { setUp(); } | ||
void setUp(); | ||
|
||
void after(bool caught) { tearDown(caught); } | ||
void tearDown(bool caught); | ||
|
||
TEST(testEnableFromTopState, -1); | ||
void testEnableFromTopState(); | ||
|
||
TEST(testEnableAndDisableInSubstatesFromTopState, -1); | ||
void testEnableAndDisableInSubstatesFromTopState(); | ||
|
||
TEST(testCannotDisableInSubstate, -1); | ||
void testCannotDisableInSubstate(); | ||
|
||
TEST(testEnableFromSubstate, -1); | ||
void testEnableFromSubstate(); | ||
|
||
TEST(testEnableInSubstatesFromSubstate, -1); | ||
void testEnableInSubstatesFromSubstate(); | ||
|
||
TEST(testSubstateWhenDisabledInSubstates, -1); | ||
void testSubstateWhenDisabledInSubstates(); | ||
}; | ||
|
||
#endif /* SvsTests_cpp */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters