Skip to content

Commit

Permalink
test(*): fixing broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
notthetup committed Jan 16, 2024
1 parent fde650c commit 197f453
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 27 deletions.
9 changes: 9 additions & 0 deletions gateways/c/tests/test_fjage.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ static void test_assert(const char* name, int pass) {

static void test_summary(void) {
printf("\n*** %d test(s) PASSED, %d test(s) FAILED ***\n\n", passed, failed);

}

static void send_report(fjage_gw_t gw){
fjage_msg_t msg = fjage_msg_create("org.arl.fjage.test.TestCompleteNtf", FJAGE_INFORM);
fjage_msg_set_recipient(msg, fjage_aid_create("test"));
fjage_msg_add_bool(msg, "status", failed == 0);
fjage_send(gw, msg);
}

static int error(const char* msg) {
Expand Down Expand Up @@ -251,6 +259,7 @@ int main(int argc, char* argv[]) {
aid = fjage_aid_topic("mytopic");
test_assert("set param (-string)", fjage_param_set_string(gw, aid, "dummy", "dummy", -1) < 0);
fjage_aid_destroy(aid);
send_report(gw);
test_assert("close", fjage_close(gw) == 0);
test_summary();
return failed;
Expand Down
Empty file modified src/test/groovy/org/arl/fjage/test/BasicTests.py
100644 → 100755
Empty file.
37 changes: 30 additions & 7 deletions src/test/groovy/org/arl/fjage/test/fjagecTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,46 @@ class fjagecTest {
@Test
void fjageCTest() {
if (System.getProperty("os.name").startsWith("Windows")) return // skip on Windows
def testResult = false
def testPending = true
def platform = new RealTimePlatform()
def container = new MasterContainer(platform, 5081)
WebServer.getInstance(8080).add("/", "/org/arl/fjage/web")
Connector conn = new WebSocketConnector(8080, "/shell/ws")
def shell = new ShellAgent(new ConsoleShell(conn), new GroovyScriptEngine())
container.addConnector(new WebSocketConnector(8080, "/ws", true))
container.add 'shell', shell
container.add('test', new Agent(){
@Override
protected void init() {
add(new MessageBehavior(){
@Override
void onReceive(Message msg) {
println("Received: " + msg.performative + ',' + msg.recipient + ',' + msg.sender)
testResult = msg.performative == Performative.AGREE
testPending = false
}
})
}
})
platform.start()
Thread.sleep(5)
def ret = 0
println "Running automated tests."
def proc = "make -C gateways/c clean test runtest".execute()
def sout = new StringBuilder(), serr = new StringBuilder()
proc.consumeProcessOutput(sout, serr)
proc.waitFor()
ret = proc.exitValue()
println "C : out = $sout \n err = $serr \n ret = $ret"
if (System.getProperty('manualCTest') == null){
println "Running automated tests."
def proc = "make -C gateways/c clean test runtest".execute()
def sout = new StringBuilder(), serr = new StringBuilder()
proc.consumeProcessOutput(sout, serr)
proc.waitFor()
ret = proc.exitValue()
println "C : out = $sout \n err = $serr \n ret = $ret"
}else{
println "waiting for user to run manual tests"
while (testPending){
platform.delay(1000)
}
println "test complete " + testPending + " : " + testResult
}
container.shutdown()
platform.shutdown()
assertEquals(ret,0)
Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/org/arl/fjage/test/fjagepyTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class fjagepyTest {
def st = platform.currentTimeMillis();
if (System.getProperty('manualPyTest') == null){
println "Running automated tests."
def proc = "python src/test/groovy/org/arl/fjage/test/BasicTests.py".execute()
def proc = "src/test/groovy/org/arl/fjage/test/BasicTests.py".execute()
def sout = new StringBuilder(), serr = new StringBuilder()
proc.consumeProcessOutput(sout, serr)
proc.waitFor()
Expand Down
38 changes: 19 additions & 19 deletions src/test/java/org/arl/fjage/test/BasicTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,14 @@ public void testListener() {
assertFalse(container.removeListener(listener));
int n1 = listener.n;
assertTrue(n1 > 0);
assertTrue(n1 == server.nuisance);
assertTrue(n1 == client.nuisance);
assertEquals(n1, server.nuisance);
assertEquals(n1, client.nuisance);
server.nuisance = 0;
client.nuisance = 0;
platform.delay(1000);
platform.shutdown();
assertTrue(n1 == listener.n);
assertTrue(server.nuisance == client.nuisance);
assertEquals(n1, listener.n);
assertEquals(server.nuisance, client.nuisance);
}

@Test
Expand All @@ -393,13 +393,13 @@ public void testListener2() {
assertFalse(container.removeListener(listener));
int n1 = listener.n;
assertTrue(n1 > 0);
assertTrue(n1 == client.nuisance);
assertTrue(server.nuisance == 0);
assertEquals(n1,client.nuisance);
assertEquals(server.nuisance,0);
server.nuisance = 0;
client.nuisance = 0;
platform.delay(1000);
platform.shutdown();
assertTrue(n1 == listener.n);
assertEquals(n1,listener.n);
assertTrue(server.nuisance > 0);
}

Expand All @@ -423,10 +423,10 @@ public void testParam1() {
log.info("Successful: "+(client1.count + client2.count + client3.count));
log.info("Warnings: "+(client1.warnings + client2.warnings + client3.warnings));
log.info("Errors: "+(server.errors + client1.errors + client2.errors + client3.errors));
assertTrue(server.errors == 0);
assertTrue(client1.errors == 0);
assertTrue(client2.errors == 0);
assertTrue(client3.errors == 0);
assertEquals(server.errors, 0);
assertEquals(client1.errors, 0);
assertEquals(client2.errors, 0);
assertEquals(client3.errors, 0);
assertTrue(client1.warnings < 3);
assertTrue(client2.warnings < 3);
assertTrue(client3.warnings < 3);
Expand All @@ -453,10 +453,10 @@ public void testParam2() {
log.info("Successful: "+(client1.count + client2.count + client3.count));
log.info("Warnings: "+(client1.warnings + client2.warnings + client3.warnings));
log.info("Errors: "+(server.errors + client1.errors + client2.errors + client3.errors));
assertTrue(server.errors == 0);
assertTrue(client1.errors == 0);
assertTrue(client2.errors == 0);
assertTrue(client3.errors == 0);
assertEquals(server.errors, 0);
assertEquals(client1.errors, 0);
assertEquals(client2.errors, 0);
assertEquals(client3.errors, 0);
assertTrue(client1.warnings < 3);
assertTrue(client2.warnings < 3);
assertTrue(client3.warnings < 3);
Expand All @@ -483,10 +483,10 @@ public void testAIDParam() {
log.info("Successful: "+(client1.count + client2.count + client3.count));
log.info("Warnings: "+(client1.warnings + client2.warnings + client3.warnings));
log.info("Errors: "+(server.errors + client1.errors + client2.errors + client3.errors));
assertTrue(server.errors == 0);
assertTrue(client1.errors == 0);
assertTrue(client2.errors == 0);
assertTrue(client3.errors == 0);
assertEquals(server.errors, 0);
assertEquals(client1.errors, 0);
assertEquals(client2.errors, 0);
assertEquals(client3.errors, 0);
assertTrue(client1.warnings < 3);
assertTrue(client2.warnings < 3);
assertTrue(client3.warnings < 3);
Expand Down

0 comments on commit 197f453

Please sign in to comment.