Skip to contentSkip to conversation

lib/igt_audio: add more assertions

PATCH In review Simon Ser 3 participants 6 messages May 23, 2019 – May 27, 2019 Library code

lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/2 lib/igt_audio: add more assertions

- Make sure an audio signal isn't created with zero channels
- Make sure each channel has at least one frequency when synthesizing

---
 lib/igt_audio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/igt_audio.c +4 -1
index 376e04ba6ed6..1677dd09c029 100644
@@ -80,6 +80,7 @@ struct audio_signal *audio_signal_init(int channels, int sampling_rate)
 {
 	struct audio_signal *signal;
 
+	igt_assert(channels > 0);
 	igt_assert(channels <= CHANNELS_MAX);
 
 	signal = malloc(sizeof(struct audio_signal));
@@ -267,8 +268,10 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
 
 	memset(buffer, 0, sizeof(double) * signal->channels * samples);
 
-	for (i = 0; i < signal->channels; i++)
+	for (i = 0; i < signal->channels; i++) {
 		freqs_per_channel[i] = audio_signal_count_freqs(signal, i);
+		igt_assert(freqs_per_channel[i]);
+	}
 
 	for (i = 0; i < signal->freqs_count; i++) {
 		freq = &signal->freqs[i];
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
author
#1 lore raw

PATCH 2/2 lib/igt_audio: use calloc instead of malloc + memset

This is less error-prone.

---
 lib/igt_audio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
lib/igt_audio.c +1 -4
index 1677dd09c029..a25288c81819 100644
@@ -83,12 +83,9 @@ struct audio_signal *audio_signal_init(int channels, int sampling_rate)
 	igt_assert(channels > 0);
 	igt_assert(channels <= CHANNELS_MAX);
 
-	signal = malloc(sizeof(struct audio_signal));
-	memset(signal, 0, sizeof(struct audio_signal));
-
+	signal = calloc(1, sizeof(struct audio_signal));
 	signal->sampling_rate = sampling_rate;
 	signal->channels = channels;
-
 	return signal;
 }
 
Signature · 6 lines
2.21.0

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#2 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/igt_audio: add more assertions

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: series starting with [i-g-t,1/2] lib/igt_audio: add more assertions
URL : https://patchwork.freedesktop.org/series/61024/
State : success

== Summary ==

CI Bug Log - changes from IGT_5008 -> IGTPW_3045
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/61024/revisions/1/mbox/

Known issues
------------

Here are the changes found in IGTPW_3045 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: [PASS][1] -> [INCOMPLETE][2] ([fdo#107718])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/fi-blb-e6850/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/fi-blb-e6850/igt@[email protected]

* igt@i915_selftest@live_contexts:
- fi-skl-gvtdvm: [PASS][3] -> [DMESG-FAIL][4] ([fdo#110235])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/fi-skl-gvtdvm/igt@i915_selftest@live_contexts.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/fi-skl-gvtdvm/igt@i915_selftest@live_contexts.html

* igt@i915_selftest@live_hangcheck:
- fi-skl-iommu: [PASS][5] -> [INCOMPLETE][6] ([fdo#108602] / [fdo#108744])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][7] -> [DMESG-WARN][8] ([fdo#102614])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/fi-hsw-peppy/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/fi-hsw-peppy/igt@[email protected]

#### Possible fixes ####

* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [FAIL][9] ([fdo#108511]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/fi-skl-6770hq/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/fi-skl-6770hq/igt@[email protected]

* igt@kms_addfb_basic@unused-pitches:
- {fi-icl-u3}: [DMESG-WARN][11] ([fdo#107724]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/fi-icl-u3/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/fi-icl-u3/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
[fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744
[fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235

Participating hosts (53 -> 46)
------------------------------

Missing (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus

Build changes
-------------

* IGT: IGT_5008 -> IGTPW_3045

CI_DRM_6129: e5d5516eb302ea0f83ea3d9014385f88ed850d53 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3045: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/
IGT_5008: 29cb27e662948b1d0710e9fdaceb5bb221746ff8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#3 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] lib/igt_audio: add more assertions

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: series starting with [i-g-t,1/2] lib/igt_audio: add more assertions
URL : https://patchwork.freedesktop.org/series/61024/
State : success

== Summary ==

CI Bug Log - changes from IGT_5008_full -> IGTPW_3045_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/61024/revisions/1/mbox/

Known issues
------------

Here are the changes found in IGTPW_3045_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_workarounds@suspend-resume-context:
- shard-glk: [PASS][1] -> [FAIL][2] ([fdo#103375])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-glk3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-glk4/igt@[email protected]

* igt@i915_suspend@fence-restore-untiled:
- shard-apl: [PASS][3] -> [DMESG-WARN][4] ([fdo#108566]) +7 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-apl6/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-apl6/igt@[email protected]

* igt@kms_cursor_crc@pipe-c-cursor-256x256-sliding:
- shard-apl: [PASS][5] -> [FAIL][6] ([fdo#103232]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-apl2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-apl5/igt@[email protected]
- shard-kbl: [PASS][7] -> [FAIL][8] ([fdo#103232])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-kbl7/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-kbl6/igt@[email protected]

* igt@kms_flip@2x-plain-flip-interruptible:
- shard-hsw: [PASS][9] -> [SKIP][10] ([fdo#109271]) +16 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-hsw7/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-hsw5/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-glk: [PASS][11] -> [FAIL][12] ([fdo#105363])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-glk7/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-glk8/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt:
- shard-iclb: [PASS][13] -> [FAIL][14] ([fdo#103167]) +5 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb8/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt.html

* igt@kms_psr@psr2_primary_mmap_gtt:
- shard-iclb: [PASS][15] -> [SKIP][16] ([fdo#109441]) +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb2/igt@kms_psr@psr2_primary_mmap_gtt.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb6/igt@kms_psr@psr2_primary_mmap_gtt.html

#### Possible fixes ####

* igt@gem_eio@reset-stress:
- shard-snb: [FAIL][17] ([fdo#109661]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-snb5/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-snb1/igt@[email protected]

* igt@gem_mmap_gtt@forked-medium-copy-xy:
- shard-iclb: [INCOMPLETE][19] ([fdo#107713] / [fdo#109100]) -> [PASS][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb3/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb1/igt@[email protected]

* igt@i915_suspend@debugfs-reader:
- shard-apl: [DMESG-WARN][21] ([fdo#108566]) -> [PASS][22] +5 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-apl3/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-apl4/igt@[email protected]

* igt@kms_flip@2x-flip-vs-dpms-off-vs-modeset-interruptible:
- shard-hsw: [SKIP][23] ([fdo#109271]) -> [PASS][24] +7 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-hsw5/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-hsw8/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt:
- shard-glk: [FAIL][25] ([fdo#103167]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-glk5/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-glk8/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt.html
- shard-apl: [FAIL][27] ([fdo#103167]) -> [PASS][28] +1 similar issue
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-apl6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-apl4/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-mmap-gtt.html

* igt@kms_frontbuffer_tracking@fbc-indfb-scaledprimary:
- shard-kbl: [FAIL][29] ([fdo#103167]) -> [PASS][30] +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-kbl6/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-kbl7/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-shrfb-draw-pwrite:
- shard-iclb: [FAIL][31] ([fdo#103167]) -> [PASS][32] +3 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-shrfb-draw-pwrite.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb1/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-pri-shrfb-draw-pwrite.html

* igt@kms_psr@no_drrs:
- shard-iclb: [FAIL][33] ([fdo#108341]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb1/igt@kms_psr@no_drrs.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb8/igt@kms_psr@no_drrs.html

* igt@kms_psr@psr2_cursor_render:
- shard-iclb: [SKIP][35] ([fdo#109441]) -> [PASS][36] +1 similar issue
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb7/igt@kms_psr@psr2_cursor_render.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb2/igt@kms_psr@psr2_cursor_render.html

* igt@kms_sysfs_edid_timing:
- shard-iclb: [FAIL][37] ([fdo#100047]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb2/igt@kms_sysfs_edid_timing.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb6/igt@kms_sysfs_edid_timing.html

#### Warnings ####

* igt@gem_mmap_gtt@forked-big-copy-odd:
- shard-iclb: [TIMEOUT][39] ([fdo#109673]) -> [INCOMPLETE][40] ([fdo#107713] / [fdo#109100])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb3/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb2/igt@[email protected]

* igt@gem_mmap_gtt@forked-big-copy-xy:
- shard-iclb: [INCOMPLETE][41] ([fdo#107713] / [fdo#109100]) -> [TIMEOUT][42] ([fdo#109673]) +1 similar issue
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGT_5008/shard-iclb1/igt@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/shard-iclb3/igt@[email protected]

[fdo#100047]: https://bugs.freedesktop.org/show_bug.cgi?id=100047
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109661]: https://bugs.freedesktop.org/show_bug.cgi?id=109661
[fdo#109673]: https://bugs.freedesktop.org/show_bug.cgi?id=109673

Participating hosts (7 -> 6)
------------------------------

Missing (1): shard-skl

Build changes
-------------

* IGT: IGT_5008 -> IGTPW_3045

CI_DRM_6129: e5d5516eb302ea0f83ea3d9014385f88ed850d53 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3045: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/
IGT_5008: 29cb27e662948b1d0710e9fdaceb5bb221746ff8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3045/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 1/2
#4 lore raw
In reply to Simon Ser
Quoted 21 lines · Simon Ser

- Make sure an audio signal isn't created with zero channels
- Make sure each channel has at least one frequency when synthesizing

---
 lib/igt_audio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/igt_audio.c +1 -0
index 376e04ba6ed6..1677dd09c029 100644
@@ -80,6 +80,7 @@ struct audio_signal *audio_signal_init(int channels, int sampling_rate)
 {
 	struct audio_signal *signal;
 
+	igt_assert(channels > 0);
 	igt_assert(channels <= CHANNELS_MAX);
 
 	signal = malloc(sizeof(struct audio_signal));

lib/igt_audio.c void audio_signal_fill(struct audio_signal *signal, double *buffer, · line 273

Quoted 7 lines
lib/igt_audio.c +2 -1
@@ -267,8 +268,10 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
 
 	memset(buffer, 0, sizeof(double) * signal->channels * samples);
 
-	for (i = 0; i < signal->channels; i++)
+	for (i = 0; i < signal->channels; i++) {
 		freqs_per_channel[i] = audio_signal_count_freqs(signal, i);
+		igt_assert(freqs_per_channel[i]);

IMO, adding > 0 would be clearer.

With this done, the series is:

lib/igt_audio.c void audio_signal_fill(struct audio_signal *signal, double *buffer, · line 277

Quoted 5 lines
lib/igt_audio.c +1 -0
+	}
 
 	for (i = 0; i < signal->freqs_count; i++) {
 		freq = &signal->freqs[i];

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

author
#5 lore raw
Quoted 24 lines · Martin Peres
Quoted 22 lines · Simon Ser

- Make sure an audio signal isn't created with zero channels
- Make sure each channel has at least one frequency when synthesizing

---
 lib/igt_audio.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/igt_audio.c +1 -0
index 376e04ba6ed6..1677dd09c029 100644
@@ -80,6 +80,7 @@ struct audio_signal *audio_signal_init(int channels, int sampling_rate)
 {
 	struct audio_signal *signal;
 
+	igt_assert(channels > 0);
 	igt_assert(channels <= CHANNELS_MAX);
 
 	signal = malloc(sizeof(struct audio_signal));
@@ -267,8 +268,10 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
 
Quoted 8 lines

lib/igt_audio.c void audio_signal_fill(struct audio_signal *signal, double *buffer, · line 273

Quoted 6 lines
lib/igt_audio.c +2 -1
 	memset(buffer, 0, sizeof(double) * signal->channels * samples);
 
-	for (i = 0; i < signal->channels; i++)
+	for (i = 0; i < signal->channels; i++) {
 		freqs_per_channel[i] = audio_signal_count_freqs(signal, i);
+		igt_assert(freqs_per_channel[i]);

IMO, adding > 0 would be clearer.

Ah. I prefer adding explicit conditions like this too, but I had a feeling the hardcore computer touchers out there wouldn't like it. :)

Will change it.

Quoted 9 lines

With this done, the series is:

lib/igt_audio.c void audio_signal_fill(struct audio_signal *signal, double *buffer, · line 277

Quoted 5 lines
lib/igt_audio.c +1 -0
+	}
 
 	for (i = 0; i < signal->freqs_count; i++) {
 		freq = &signal->freqs[i];

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev