Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a werk_test crate to contain test binaries for the opus testsuite
This works like this: * build.rs of the werk crate compiles libopus into a static library * build.rs of the werk_test crate compiles the test programs into static libraries, each with still unresolved dependencies to libopus * werk_test contains a binary for each test binary. Each binary has: * #![no_main] in order to not create any rust based main machinery * #[link(name="...", kind="static")] extern {} in order to use the main provided by the C test executable * extern crate werk test; in order to get libopus linked The proposed process is as following: * Piece by piece we port over libopus from C to Rust, into the werk crate. * The API gets retained, so usable by the test code * The test code gets rewritten in Rust. * The API gets rustified component per component * All while never really breaking the testsuite. If it gets broken, we immediately know which part of the rewrite to blame. Of course while there is dependence between these steps, they can be mixed to some degree.
- Loading branch information
Showing
6 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[workspace] | ||
members = ["werk"] | ||
members = [ | ||
"werk", | ||
"werk_test", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "werk_test" | ||
version = "0.1.0" | ||
authors = ["est31 <MTest31@outlook.com>", "The opus project developers"] | ||
license = "BSD-3-Clause" | ||
|
||
[dependencies] | ||
werk = { path = "../werk" } | ||
|
||
[build-dependencies] | ||
gcc = "0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Werk - a pure Rust opus library | ||
// | ||
// Copyright (c) 2001-2011 the opus developers, and | ||
// Copyright (c) 2017 est31 <MTest31@outlook.com> | ||
// and contributors, All rights reserved. | ||
// Licensed under the BSD 3 clause license. | ||
// Please see the COPYING file attached to | ||
// this source distribution for details. | ||
|
||
extern crate gcc; | ||
|
||
use gcc::Config; | ||
|
||
macro_rules! test_program { | ||
($name:ident; $($($pathseg:ident)/ *.c),*; $libname:expr) => { | ||
fn $name() { | ||
let mut cfg = Config::new(); | ||
cfg | ||
.include("../libopus/include") | ||
.include("../libopus/celt") | ||
.include("../libopus/silk") | ||
.include("../libopus/silk/fixed") | ||
.include("../libopus/silk/float") | ||
// Note in configure.ac there are a bunch of such variables defined, | ||
// each with AC_DEFINE. | ||
// But these two are the required ones | ||
.define("OPUS_BUILD", None) | ||
.define("USE_ALLOCA", None); | ||
// Always optimize, this is no fun otherwise | ||
cfg.opt_level(3); | ||
cfg $(.file(concat!("../libopus/", | ||
$("/", stringify!($pathseg)),*, | ||
".c" | ||
)))*; | ||
cfg.compile($libname); | ||
} | ||
} | ||
} | ||
|
||
test_program! { compile_test_opus_decode; | ||
tests/test_opus_decode.c; | ||
"libopus_decode.a" | ||
} | ||
|
||
test_program! { compile_test_opus_encode; | ||
tests/test_opus_encode.c, | ||
tests/opus_encode_regressions.c; | ||
"libopus_encode.a" | ||
} | ||
|
||
// TODO: add other tests | ||
|
||
|
||
fn main() { | ||
compile_test_opus_decode(); | ||
compile_test_opus_encode(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Werk - a pure Rust opus library | ||
// | ||
// Copyright (c) 2001-2011 the opus developers, and | ||
// Copyright (c) 2017 est31 <MTest31@outlook.com> | ||
// and contributors, All rights reserved. | ||
// Licensed under the BSD 3 clause license. | ||
// Please see the COPYING file attached to | ||
// this source distribution for details. | ||
|
||
#![no_main] | ||
|
||
extern crate werk_test; | ||
|
||
#[link(name="opus_decode", kind="static")] | ||
extern {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Werk - a pure Rust opus library | ||
// | ||
// Copyright (c) 2001-2011 the opus developers, and | ||
// Copyright (c) 2017 est31 <MTest31@outlook.com> | ||
// and contributors, All rights reserved. | ||
// Licensed under the BSD 3 clause license. | ||
// Please see the COPYING file attached to | ||
// this source distribution for details. | ||
|
||
#![no_main] | ||
|
||
extern crate werk_test; | ||
|
||
#[link(name="opus_encode", kind="static")] | ||
extern {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Werk - a pure Rust opus library | ||
// | ||
// Copyright (c) 2001-2011 the opus developers, and | ||
// Copyright (c) 2017 est31 <MTest31@outlook.com> | ||
// and contributors, All rights reserved. | ||
// Licensed under the BSD 3 clause license. | ||
// Please see the COPYING file attached to | ||
// this source distribution for details. | ||
|
||
extern crate werk; |