Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
71b5d0d9
Verified
Commit
71b5d0d9
authored
1 year ago
by
João Magalhães
Browse files
Options
Downloads
Patches
Plain Diff
chore: comparison of instr_timing image
Also added support for image saving.
parent
ca57680c
No related branches found
No related tags found
No related merge requests found
Pipeline
#3005
passed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontends/sdl/res/test/blargg/instr_timing/instr_timing.png
+0
-0
0 additions, 0 deletions
frontends/sdl/res/test/blargg/instr_timing/instr_timing.png
frontends/sdl/src/test.rs
+27
-2
27 additions, 2 deletions
frontends/sdl/src/test.rs
with
27 additions
and
2 deletions
frontends/sdl/res/test/blargg/instr_timing/instr_timing.png
0 → 100644
+
0
−
0
View file @
71b5d0d9
1.51 KiB
This diff is collapsed.
Click to expand it.
frontends/sdl/src/test.rs
+
27
−
2
View file @
71b5d0d9
use
image
::
io
::
Reader
as
ImageReader
;
use
image
::
{
io
::
Reader
as
ImageReader
,
ImageBuffer
,
Rgb
}
;
pub
fn
compare_images
(
source_pixels
:
&
[
u8
],
target_path
:
&
str
)
->
bool
{
pub
fn
compare_images
(
source_pixels
:
&
[
u8
],
target_path
:
&
str
)
->
bool
{
let
image_buffer
=
ImageReader
::
open
(
target_path
)
let
image_buffer
=
ImageReader
::
open
(
target_path
)
...
@@ -23,6 +23,19 @@ pub fn compare_images(source_pixels: &[u8], target_path: &str) -> bool {
...
@@ -23,6 +23,19 @@ pub fn compare_images(source_pixels: &[u8], target_path: &str) -> bool {
true
true
}
}
pub
fn
save_image
(
pixels
:
&
[
u8
],
width
:
u32
,
height
:
u32
,
file_path
:
&
str
)
{
let
mut
image_buffer
:
ImageBuffer
<
Rgb
<
u8
>
,
Vec
<
u8
>>
=
ImageBuffer
::
new
(
width
,
height
);
for
(
x
,
y
,
pixel
)
in
image_buffer
.enumerate_pixels_mut
()
{
let
base
=
((
y
*
width
+
x
)
*
3
)
as
usize
;
*
pixel
=
Rgb
([
pixels
[
base
],
pixels
[
base
+
1
],
pixels
[
base
+
2
]]);
}
image_buffer
.save_with_format
(
file_path
,
image
::
ImageFormat
::
Png
)
.unwrap
();
}
#[cfg(test)]
#[cfg(test)]
mod
tests
{
mod
tests
{
use
boytacean
::{
use
boytacean
::{
...
@@ -31,7 +44,7 @@ mod tests {
...
@@ -31,7 +44,7 @@ mod tests {
test
::{
run_image_test
,
TestOptions
},
test
::{
run_image_test
,
TestOptions
},
};
};
use
super
::
compare_images
;
use
super
::
{
compare_images
,
save_image
}
;
#[test]
#[test]
fn
test_blargg_cpu_instrs
()
{
fn
test_blargg_cpu_instrs
()
{
...
@@ -44,6 +57,18 @@ mod tests {
...
@@ -44,6 +57,18 @@ mod tests {
assert_eq!
(
image_result
,
true
);
assert_eq!
(
image_result
,
true
);
}
}
#[test]
fn
test_blargg_instr_timing
()
{
let
result
:
[
u8
;
FRAME_BUFFER_SIZE
]
=
run_image_test
(
"../../res/roms/test/blargg/instr_timing/instr_timing.gb"
,
Some
(
50000000
),
TestOptions
::
default
(),
);
compare_images
(
&
result
,
"res/test/blargg/instr_timing/instr_timing.png"
);
let
image_result
=
compare_images
(
&
result
,
"res/test/blargg/instr_timing/instr_timing.png"
);
assert_eq!
(
image_result
,
true
);
}
#[test]
#[test]
fn
test_dmg_acid2
()
{
fn
test_dmg_acid2
()
{
let
result
:
[
u8
;
FRAME_BUFFER_SIZE
]
=
run_image_test
(
let
result
:
[
u8
;
FRAME_BUFFER_SIZE
]
=
run_image_test
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment