test(updater): copy over and port tests to nusystem

All testsuites have been copied over from SynthOS updater and syntax has been corrected for the most part in the various testsuites.

Signed-off-by: zontreck <tarapiccari@gmail.com>
This commit is contained in:
zontreck 2024-10-05 02:10:41 -07:00
parent 737045ecf7
commit 993b6feee4
8 changed files with 317 additions and 1 deletions

View file

@ -16,7 +16,11 @@ CancelCallback(string sTimerID) {
} }
string BuildPacket(string sOperation, list lParams) { string BuildPacket(string sOperation, list lParams) {
return llList2Json(JSON_OBJECT, lParams + ["op", sOperation]); return llList2Json(JSON_OBJECT, lParams + ["op", sOperation, "info", BuildInfoPacket()]);
}
string BuildInfoPacket() {
return llList2Json(JSON_OBJECT, ["script", llGetScriptName(), "time", llGetUnixTime()]);
} }

View file

@ -29,6 +29,7 @@ string VERSION = "0.3.0-dev";
integer UPDATER_CHANNEL = 0xABCDE0; integer UPDATER_CHANNEL = 0xABCDE0;
integer PACKAGE_SERVER_CHANNEL = 0xAACEA; // AriA's CrEAtions

View file

@ -0,0 +1,24 @@
#include "Variables.lsl"
#include "Functions.lsl"
#include "Version.lsl"
#include "../external/AriasCreations/Common.lsl"
#include "../external/AriasCreations/Helpers.lsl"
// When used in combination with the Test manifest
// {"op":"package_server_reply","info":{"origin":"New Script","time":1667966332},"server":"Test Server"}
//
// Test status: PASS
default
{
state_entry()
{
g_iServerListener = llListen(PACKAGE_SERVER_CHANNEL, "", "", "");
llRegionSay(PACKAGE_SERVER_CHANNEL, BuildPacket("check_package_servers",[]));
}
listen(integer c,string n,key i,string m)
{
llSay(0, "REPLIES: "+m);
}
}

View file

@ -0,0 +1,33 @@
#include "Variables.lsl"
#include "Functions.lsl"
#include "Version.lsl"
#include "../external/AriasCreations/Common.lsl"
#include "../external/AriasCreations/Helpers.lsl"
// When used in combination with the Test manifest
// {"op":"package_list","info":{"origin":"New Script","time":1667966574},"packages":["Test"]}
//
// Test status: PASS
default
{
state_entry()
{
g_iServerListener = llListen(PACKAGE_SERVER_CHANNEL, "", "", "");
llRegionSay(PACKAGE_SERVER_CHANNEL, BuildPacket("check_package_servers",[]));
}
listen(integer c,string n,key i,string m)
{
if(llJsonGetValue(m,["op"]) == "package_server_reply")
{
if(llJsonGetValue(m,["server"]) == "Test Server")
{
llRegionSayTo(i,c,Build("connect", []));
}
}else if(llJsonGetValue(m,["op"]) == "package_list")
{
llSay(0, "REPLY: "+m);
}
}
}

View file

@ -0,0 +1,44 @@
#include "Variables.lsl"
#include "Functions.lsl"
#include "Version.lsl"
#include "../external/AriasCreations/Common.lsl"
#include "../external/AriasCreations/Helpers.lsl"
// When used in combination with the Test manifest
// {"op":"package_versions","info":{"origin":"New Script","time":1667967045},"Test":["0.1.0.0","0.1.0.1"]}
//
// Test status: PASS
default
{
state_entry()
{
g_iServerListener = llListen(PACKAGE_SERVER_CHANNEL, "", "", "");
llRegionSay(PACKAGE_SERVER_CHANNEL, BuildPacket("check_package_servers",[]));
}
listen(integer c,string n,key i,string m)
{
if(llJsonGetValue(m,["op"]) == "package_server_reply")
{
if(llJsonGetValue(m,["server"]) == "Test Server")
{
llRegionSayTo(i,c,BuildPacket("connect", []));
}else {
//llSay(0, "FATAL ERROR IN PACKAGE SERVER REPLY");
}
}else if(llJsonGetValue(m,["op"]) == "package_list")
{
string sPkgs = llJsonGetValue(m,["packages"]);
if(sPkgs == "[\"Test\"]")
{
llRegionSayTo(i,c,BuildPacket("check_package", ["pkg", "Test"]));
}else {
llSay(0, "FATAL ERROR IN PACKAGE SERVER LISTING");
}
} else if(llJsonGetValue(m,["op"]) == "package_versions")
{
llSay(0, "VERSIONS: "+m);
}
}
}

View file

@ -0,0 +1,100 @@
#include "Variables.lsl"
#include "Functions.lsl"
#include "Version.lsl"
#include "../external/AriasCreations/Common.lsl"
#include "../external/AriasCreations/Helpers.lsl"
// When used in combination with the Test manifest
/*
CHECK 1: {"op":"version_back","info":{"origin":"New Script","time":1667970061},"same":0,"newer":1,"compatible":1}
CHECK 2: {"op":"version_back","info":{"origin":"New Script","time":1667970061},"same":0,"newer":1,"compatible":0}
CHECK 3: {"op":"version_back","info":{"origin":"New Script","time":1667970061},"same":0,"newer":1,"compatible":1}
CHECK 4: {"op":"version_back","info":{"origin":"New Script","time":1667970199},"same":1,"newer":0,"compatible":1}
*/
//
// Test status: PASS
integer g_iChecks=0;
default
{
state_entry()
{
VERSION = "0.0.1.0";
g_iServerListener = llListen(PACKAGE_SERVER_CHANNEL, "", "", "");
llRegionSay(PACKAGE_SERVER_CHANNEL, BuildPacket("check_package_servers",[]));
}
listen(integer c,string n,key i,string m)
{
if(llJsonGetValue(m,["op"]) == "package_server_reply")
{
if(llJsonGetValue(m,["server"]) == "Test Server")
{
llRegionSayTo(i,c,BuildPacket("connect", []));
}else {
llSay(0, "FATAL ERROR IN PACKAGE SERVER REPLY");
}
}else if(llJsonGetValue(m,["op"]) == "package_list")
{
string sPkgs = llJsonGetValue(m,["packages"]);
if(sPkgs == "[\"Test\"]")
{
llRegionSayTo(i,c,BuildPacket("check_package", ["pkg", "Test"]));
}else {
llSay(0, "FATAL ERROR IN PACKAGE SERVER LISTING");
}
} else if(llJsonGetValue(m,["op"]) == "package_versions")
{
g_iChecks=0;
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg","Test","ver", "0.1.0.0", "cur", VERSION]));
} else if(llJsonGetValue(m,["op"]) == "version_back")
{
// Test 1 we check 0.1.0.0
// Test 2 we check 0.1.0.1
// Testsuite A will only check with version number 0.0.0.1-EXTRA
// Testsuite B will test with its version number being 1.0.0.0
if(!(g_iChecks & 1))
{
g_iChecks++;
llSay(0, "CHECK 1: "+m);
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg","Test", "ver", "0.1.0.1", "cur", VERSION]));
} else if(!(g_iChecks & 2))
{
g_iChecks = g_iChecks << 1;
llSay(0, "CHECK 2: "+m);
// We are updating!
VERSION = "0.1.0.0";
g_iChecks++;
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg", "Test", "ver", "0.1.0.1", "cur", VERSION]));
}else if(!(g_iChecks & 4))
{
g_iChecks = g_iChecks << 1;
llSay(0, "CHECK 3: "+m);
g_iChecks++;
// Check the same version to us
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg", "Test", "ver", "0.1.0.0", "cur", VERSION]));
} else if(!(g_iChecks & 8))
{
g_iChecks = g_iChecks<<1;
g_iChecks++;
llSay(0, "CHECK 4: "+m);
}
}
}
}

View file

@ -0,0 +1,104 @@
#include "Variables.lsl"
#include "Functions.lsl"
#include "Version.lsl"
#include "../external/AriasCreations/Common.lsl"
#include "../external/AriasCreations/Helpers.lsl"
// When used in combination with the Test manifest
/*
[21:10:16] Object: Send_back received
[21:10:16] Object: Item 'Test0100' is in the inventory
*/
//
// Test status: PASS
integer g_iChecks=0;
default
{
state_entry()
{
VERSION = "0.0.1.0";
g_iServerListener = llListen(PACKAGE_SERVER_CHANNEL, "", "", "");
llRegionSay(PACKAGE_SERVER_CHANNEL, BuildPacket("check_package_servers",[]));
}
listen(integer c,string n,key i,string m)
{
if(llJsonGetValue(m,["op"]) == "package_server_reply")
{
if(llJsonGetValue(m,["server"]) == "Test Server")
{
llRegionSayTo(i,c,BuildPacket("connect", []));
}else {
llSay(0, "FATAL ERROR IN PACKAGE SERVER REPLY");
}
}else if(llJsonGetValue(m,["op"]) == "package_list")
{
string sPkgs = llJsonGetValue(m,["packages"]);
if(sPkgs == "[\"Test\"]")
{
llRegionSayTo(i,c,BuildPacket("check_package", ["pkg", "Test"]));
}else {
llSay(0, "FATAL ERROR IN PACKAGE SERVER LISTING");
}
} else if(llJsonGetValue(m,["op"]) == "package_versions")
{
g_iChecks=0;
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg","Test","ver", "0.1.0.0", "cur", VERSION]));
} else if(llJsonGetValue(m,["op"]) == "version_back")
{
// Test 1 we check 0.1.0.0
// Test 2 we check 0.1.0.1
// Testsuite A will only check with version number 0.0.0.1-EXTRA
// Testsuite B will test with its version number being 1.0.0.0
if(!(g_iChecks & 1))
{
g_iChecks++;
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg","Test", "ver", "0.1.0.1", "cur", VERSION]));
} else if(!(g_iChecks & 2))
{
g_iChecks = g_iChecks << 1;
// We are updating!
VERSION = "0.1.0.0";
g_iChecks++;
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg", "Test", "ver", "0.1.0.1", "cur", VERSION]));
}else if(!(g_iChecks & 4))
{
g_iChecks = g_iChecks << 1;
g_iChecks++;
// Check the same version to us
llRegionSayTo(i,c,BuildPacket("check_version", ["pkg", "Test", "ver", "0.1.0.0", "cur", VERSION]));
} else if(!(g_iChecks & 8))
{
g_iChecks = g_iChecks<<1;
g_iChecks++;
if(llGetOwnerKey(i)!=llGetOwner())llAllowInventoryDrop(TRUE);
llRegionSayTo(i,c,BuildPacket("send", ["pkg", "Test", "ver", "0.1.0.0", "dest", llGetKey()]));
}
} else if(llJsonGetValue(m,["op"]) == "send_back")
{
llAllowInventoryDrop(FALSE);
llSay(0, "Send_back received");
if(llGetInventoryType(llJsonGetValue(m,["item"])) != INVENTORY_NONE)
{
llSay(0, "Item '"+llJsonGetValue(m,["item"])+"' is in the inventory");
} else{
llSay(0, "Item from server not found");
}
}
}
}

View file

@ -0,0 +1,6 @@
SERVER_NAME Test Server
BEGIN Test
LATEST 0.1.0.1
0.1.0.0|Test0100|0.0.1.0
0.1.0.1|Test0101|0.1.0.0
END