63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
require_once "vendor/autoload.php";
|
|
|
|
require_once "class/TestMgr.php";
|
|
require_once "class/GameMgr.php";
|
|
|
|
require_once "class/LogicFunction.php";
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
const longopts = [
|
|
"action:", // execute some CLI action
|
|
"tick", // tick timed objects (e.g. timed tests)
|
|
];
|
|
|
|
$options = getopt("", longopts);
|
|
|
|
// CLI actions
|
|
if (isset($options["action"])) {
|
|
$action = $options["action"];
|
|
|
|
switch ($action) {
|
|
case "upgrade_tests":
|
|
{
|
|
printf("Upgrading tests...");
|
|
$testMgr = new TestMgr();
|
|
$testMgr->upgradeTests();
|
|
printf("OK!\n");
|
|
}
|
|
break;
|
|
case "upgrade_games":
|
|
{
|
|
printf("Upgrading games...");
|
|
$gameMgr = new GameMgr();
|
|
$gameMgr->upgradeGames();
|
|
printf("OK!\n");
|
|
}
|
|
break;
|
|
case "get_timed_tests":
|
|
{
|
|
$testMgr = new TestMgr();
|
|
printf("Expired timed tests: %s\n", join(", ", $testMgr->extractExpiredTimedTestIds()));
|
|
}
|
|
break;
|
|
case "gen_random":
|
|
{
|
|
//$lf = LogicFunction::genRandom(["a", "b", "c"], 2, 4);
|
|
$lf = LogicFunction::genRandomDF(["a", "b", "c"]);
|
|
printf("Verilog-form: %s\nTeX-form: %s\n", $lf->verilog_form, $lf->tex_form);
|
|
$lf->getTruthTable();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Tick tests
|
|
if (isset($options["tick"])) {
|
|
$testMgr = new TestMgr();
|
|
$timedTestIDs = $testMgr->extractExpiredTimedTestIds();
|
|
$testMgr->upgradeTests($timedTestIDs);
|
|
}
|