Skip to content

Commit

Permalink
Fix memory-based check failing on Intel arch due to padding data
Browse files Browse the repository at this point in the history
  • Loading branch information
rhargreaves committed Aug 28, 2024
1 parent f567008 commit 4419f71
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
30 changes: 30 additions & 0 deletions tests/asserts.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,33 @@ void _expect_ym2612_write_channel_any_data(
{
_expect_ym2612_write_reg_any_data(REG_PART(chan), baseReg + REG_OFFSET(chan), file, line);
}

static bool operator_equality_check(Operator* l, Operator* r)
{
return ((l->amplitudeModulation == r->amplitudeModulation) && (l->attackRate == r->attackRate)
&& (l->decayRate == r->decayRate) && (l->detune == r->detune)
&& (l->multiple == r->multiple) && (l->rateScaling == r->rateScaling)
&& (l->releaseRate == r->releaseRate) && (l->ssgEg == r->ssgEg)
&& (l->sustainLevel == r->sustainLevel) && (l->sustainRate == r->sustainRate)
&& (l->totalLevel == r->totalLevel));
}

int fmchannel_equality_check(
const LargestIntegralType value, const LargestIntegralType check_value_data)
{
FmChannel* expected = (FmChannel*)value;
FmChannel* actual = (FmChannel*)check_value_data;

if ((actual->algorithm == expected->algorithm) && (actual->ams == expected->ams)
&& (actual->feedback == expected->feedback) && (actual->fms == expected->fms)
&& (actual->freqNumber == expected->freqNumber) && (actual->octave == expected->octave)
&& (actual->stereo == expected->stereo)
&& operator_equality_check(&actual->operators[0], &expected->operators[0])
&& operator_equality_check(&actual->operators[1], &expected->operators[1])
&& operator_equality_check(&actual->operators[2], &expected->operators[2])
&& operator_equality_check(&actual->operators[3], &expected->operators[3])) {
return 1;
}

return 0;
}
3 changes: 3 additions & 0 deletions tests/asserts.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ void _expect_ym2612_write_channel_any_data(
void _expect_ym2612_write_operator(
u8 chan, u8 op, u8 baseReg, u8 data, const char* const file, const int line);

int fmchannel_equality_check(
const LargestIntegralType value, const LargestIntegralType check_value_data);

#define REG_PART(chan) (chan < 3 ? 0 : 1)
#define REG_OFFSET(chan) (chan % 3)

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_midi_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ static void test_midi_fm_note_on_percussion_channel_sets_percussion_preset(UNUSE
{ 4, 0, 31, 2, 20, 0, 15, 0, 15, 13, 0 }, { 2, 0, 31, 2, 20, 0, 15, 0, 15, 13, 0 } } };

expect_value(__wrap_synth_preset, channel, FM_CHANNEL);
expect_memory(__wrap_synth_preset, preset, &P_BANK_0_INST_30_CASTANETS,
sizeof(P_BANK_0_INST_30_CASTANETS));
expect_check(
__wrap_synth_preset, preset, fmchannel_equality_check, &P_BANK_0_INST_30_CASTANETS);

expect_synth_volume_any();
expect_synth_pitch(FM_CHANNEL, 0, 0x32a);
Expand Down

0 comments on commit 4419f71

Please sign in to comment.