1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
/*
* Copyright 2009- ECMWF.
*
* This software is licensed under the terms of the Apache Licence version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <boost/test/unit_test.hpp>
#include "ServerTestHarness.hpp"
#include "ecflow/attribute/VerifyAttr.hpp"
#include "ecflow/core/Timer.hpp"
#include "ecflow/node/Defs.hpp"
#include "ecflow/node/Family.hpp"
#include "ecflow/node/Suite.hpp"
#include "ecflow/node/Task.hpp"
#include "ecflow/test/scaffold/Naming.hpp"
using namespace std;
using namespace ecf;
BOOST_AUTO_TEST_SUITE(S_Test)
BOOST_AUTO_TEST_SUITE(T_EcfNoScriptCmd)
BOOST_AUTO_TEST_CASE(test_ecf_no_script) {
ECF_NAME_THIS_TEST();
// This test is used to case where we ONLY want to execute ECF_JOB_CMD WITHOUT processing .ecf script.
// For this ECF_NO_SCRIPT must be set to any value.
// The ECF_JOB_CMD must then encompass ecflow_client --init/complete and the environment settings
// Additionally the user can see the output by directing the word done to ECF_JOBOUT
// Although ServerTestHarness creates the .ecf file, they are ignored when ECF_NO_SCRIPT is specified.
DurationTimer timer;
TestClean clean_at_start_and_end;
// Create the defs file corresponding to the text below
// ECF_HOME variable is automatically added by the test harness.
// ECF_INCLUDE variable is automatically added by the test harness.
// SLEEPTIME variable is automatically added by the test harness.
// ECF_CLIENT_EXE_PATH variable is automatically added by the test harness.
// This is substituted in sms includes
// Allows test to run without requiring installation
// # Note: we have to use relative paths, since these tests are relocatable
// suite test_ecf_no_script_cmd
// edit ECF_NO_SCRIPT 1
// edit ECF_JOB_CMD "export ECF_PASS=%ECF_PASS%;...."
// task t1
// task t2
// endfamily
// endsuite
Defs theDefs;
{
suite_ptr suite = theDefs.add_suite("test_ecf_no_script");
suite->add_variable("ECF_NO_SCRIPT", "1");
std::string ecf_job_cmd = "export ECF_PASS=%ECF_PASS%;export ECF_PORT=%ECF_PORT%;export "
"ECF_HOST=%ECF_HOST%;export ECF_NAME=%ECF_NAME%;export ECF_TRYNO=%ECF_TRYNO%;";
ecf_job_cmd += "%ECF_CLIENT_EXE_PATH% --init=$$; echo 'test test_ecf_no_script' >> %ECF_JOBOUT%; "
"%ECF_CLIENT_EXE_PATH% --complete";
suite->add_variable("ECF_JOB_CMD", ecf_job_cmd);
suite->add_task("t1")->addVerify(VerifyAttr(NState::COMPLETE, 1));
suite->add_task("t2")->addVerify(VerifyAttr(NState::COMPLETE, 1));
// cout << theDefs;
}
ServerTestHarness serverTestHarness;
serverTestHarness.run(theDefs, ServerTestHarness::testDataDefsLocation("test_ecf_no_script.def"));
cout << timer.duration() << " update-calendar-count(" << serverTestHarness.serverUpdateCalendarCount() << ")\n";
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
|