Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,140 changes: 426 additions & 714 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = ["auxcov", "auxtools", "auxtools-impl", "debug_server", "instruction_hooking", "tests/auxtest", "tests/byond_get", "tests/test_runner"]
members = ["auxcov", "auxtools", "auxtools-impl", "debug_server", "instruction_hooking", "tests/auxsigcheck", "tests/auxtest", "tests/test_runner"]
default-members = ["auxtools", "auxtools-impl", "debug_server", "instruction_hooking"]
resolver = "2"

[workspace.package]
Expand Down
18 changes: 18 additions & 0 deletions tests/auxsigcheck/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "auxsigcheck"
rust-version = "1.79"
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
byond-get = { git = "https://github.com/absolucy/byond-get" }
cfg-if = "1"
clap = { version = "4", features = ["derive"] }
color-eyre = "0.6"
tempdir = "0.3"

[lints]
workspace = true
23 changes: 23 additions & 0 deletions tests/auxsigcheck/src/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use clap::Parser;
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct Args {
/// Path to the auxtools DLL to use.
#[arg(short = 'i', long = "dll")]
pub auxtools_path: PathBuf,

/// Version of BYOND to use.
pub version: u16,

/// Build of BYOND to use.
pub build: u16
}

impl Args {
#[inline]
pub fn new() -> Self {
Self::parse()
}
}
22 changes: 22 additions & 0 deletions tests/auxsigcheck/src/dm/auxsigcheck.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#if DM_VERSION >= 515
#define LIBCALL call_ext
#else
#define LIBCALL call
#endif

/world/New()
. = ..()
var/result = run_tests()
if(!result)
world.log << "FAILED (unknown, likely runtime)"
else
world.log << "[result]"
del(src)

/proc/run_tests()
var/dll = world.GetConfig("env", "AUXTOOLS_DLL")
if(!dll)
return "FAILED (AUXTOOLS_DLL not set)"
if(!fexists(dll))
return "FAILED (AUXTOOLS_DLL path doesn't exist)"
return LIBCALL(dll, "auxtools_check_signatures")()
19 changes: 19 additions & 0 deletions tests/auxsigcheck/src/dm/auxsigcheck.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// DM Environment file for auxsigcheck.dme.
// All manual changes should be made outside the BEGIN_ and END_ blocks.
// New source code should be placed in .dm files: choose File/New --> Code File.

// BEGIN_INTERNALS
// END_INTERNALS

// BEGIN_FILE_DIR
#define FILE_DIR .
// END_FILE_DIR

// BEGIN_PREFERENCES
#define DEBUG
// END_PREFERENCES

// BEGIN_INCLUDE
#include "auxsigcheck.dm"
// END_INCLUDE

74 changes: 74 additions & 0 deletions tests/auxsigcheck/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
mod args;
mod result;

use self::{
args::Args,
result::{extract_test_result, TestResult}
};
use byond_get::OsType;
use cfg_if::cfg_if;
use color_eyre::eyre::{Result, WrapErr};
use std::process::Command;
use tempdir::TempDir;

static TEST_DM: &[u8] = include_bytes!("dm/auxsigcheck.dm");
static TEST_DME: &[u8] = include_bytes!("dm/auxsigcheck.dme");

cfg_if! {
if #[cfg(windows)] {
const OS: OsType = OsType::Windows;
const DREAMMAKER_EXE: &str = "dm.exe";
const DREAMDAEMON_EXE: &str = "dd.exe";
} else {
const OS: OsType = OsType::Linux;
const DREAMMAKER_EXE: &str = "DreamMaker";
const DREAMDAEMON_EXE: &str = "DreamDaemon";
}
}

fn main() -> Result<()> {
color_eyre::install()?;
let args = Args::new();
let auxtools_path = std::path::absolute(args.auxtools_path).wrap_err("failed to get absolute auxtools path")?;
let tmpdir = TempDir::new("auxsigcheck").wrap_err("failed to crate tempdir")?;
let base_path = tmpdir.path();

let byond_path = base_path.join("byond");
byond_get::download_bin(args.version, args.build, OS, &byond_path).wrap_err("failed to download byond")?;

std::fs::write(base_path.join("auxsigcheck.dm"), TEST_DM).wrap_err("failed to write auxsigcheck.dm")?;
std::fs::write(base_path.join("auxsigcheck.dme"), TEST_DME).wrap_err("failed to write auxsigcheck.dme")?;

let status = Command::new(byond_path.join(DREAMMAKER_EXE))
.arg(base_path.join("auxsigcheck.dme"))
.output()
.wrap_err("failed to run DreamMaker")?
.status;
if !status.success() {
panic!("Failed to compile auxsigcheck.dme, DreamMaker exited with code {status}")
}

std::env::set_var("LD_LIBRARY_PATH", byond_path.to_str().unwrap());
std::env::set_var("AUXTOOLS_DLL", auxtools_path);

let test_run = Command::new(byond_path.join(DREAMDAEMON_EXE))
.arg(base_path.join("auxsigcheck.dmb"))
.args(["-trusted", "-invisible"])
.output()
.wrap_err("failed to run DreamDaemon")?;

// cleanup env variables
std::env::remove_var("AUXTOOLS_DLL");
if !test_run.status.success() {
panic!("Failed to run auxsigcheck.dmb, DreamDaemon exited with code {status}")
}

let stderr = String::from_utf8_lossy(&test_run.stderr).into_owned();
match extract_test_result(&stderr) {
TestResult::Success => println!("success"),
TestResult::Failed(reason) => println!("failed: {reason}"),
TestResult::Missing(sigs) => println!("missing: {sigs}")
}

Ok(())
}
21 changes: 21 additions & 0 deletions tests/auxsigcheck/src/result.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pub enum TestResult {
Success,
Failed(String),
Missing(String)
}

pub fn extract_test_result(s: &str) -> TestResult {
for line in s.lines() {
let trimmed = line.trim();
if trimmed.is_empty() {
continue;
} else if trimmed.starts_with("SUCCESS") {
return TestResult::Success;
} else if trimmed.starts_with("FAILED") {
return TestResult::Failed(trimmed.split('(').nth(1).unwrap().replace(")", "").trim().to_owned());
} else if trimmed.starts_with("MISSING") {
return TestResult::Missing(trimmed.split(':').nth(1).unwrap().trim().to_owned());
}
}
panic!("No test result found")
}
11 changes: 0 additions & 11 deletions tests/byond_get/Cargo.toml

This file was deleted.

69 changes: 0 additions & 69 deletions tests/byond_get/src/main.rs

This file was deleted.

Loading