From a50c518c0b68ff10d9a27f1179bbf49af639d5f3 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:10:13 -0700 Subject: [PATCH 01/15] dai: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/dai.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/dai.c b/src/audio/dai.c index 3aba31ff3b35..f4064db1ce41 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -837,9 +837,7 @@ static struct comp_driver comp_dai = { }, }; -void sys_comp_dai_init(void); - -void sys_comp_dai_init(void) +static void sys_comp_dai_init(void) { comp_register(&comp_dai); } From 21175faf8d0db57675511fd188df26e0e339dc07 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:11:00 -0700 Subject: [PATCH 02/15] eq: fir: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/eq_fir.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/eq_fir.c b/src/audio/eq_fir.c index 5add3e303281..df922adb07b4 100644 --- a/src/audio/eq_fir.c +++ b/src/audio/eq_fir.c @@ -816,9 +816,7 @@ struct comp_driver comp_eq_fir = { }, }; -void sys_comp_eq_fir_init(void); - -void sys_comp_eq_fir_init(void) +static void sys_comp_eq_fir_init(void) { comp_register(&comp_eq_fir); } From 6519e84ce7f6eb8cdfbe6be48e4501d62bb7531e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:11:55 -0700 Subject: [PATCH 03/15] eq: iir: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/eq_iir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/audio/eq_iir.c b/src/audio/eq_iir.c index 75c739da3f13..02b0f901c77a 100644 --- a/src/audio/eq_iir.c +++ b/src/audio/eq_iir.c @@ -936,9 +936,8 @@ struct comp_driver comp_eq_iir = { }, }; -void sys_comp_eq_iir_init(void); -void sys_comp_eq_iir_init(void) +static void sys_comp_eq_iir_init(void) { comp_register(&comp_eq_iir); } From 9bc6c96382ed32406ec67ba188f12079466776c6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:12:27 -0700 Subject: [PATCH 04/15] host: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/host.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/host.c b/src/audio/host.c index fefcdae54a51..e5358755b750 100644 --- a/src/audio/host.c +++ b/src/audio/host.c @@ -855,9 +855,7 @@ struct comp_driver comp_host = { }, }; -void sys_comp_host_init(void); - -void sys_comp_host_init(void) +static void sys_comp_host_init(void) { comp_register(&comp_host); } From 1efb5a01193cba5347af61d5414196d4665dd0ee Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:12:47 -0700 Subject: [PATCH 05/15] kpb: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/kpb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/kpb.c b/src/audio/kpb.c index f5fc06072844..25f1e0a8efab 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -545,9 +545,7 @@ struct comp_driver comp_kpb = { }, }; -void sys_comp_kpb_init(void); - -void sys_comp_kpb_init(void) +static void sys_comp_kpb_init(void) { comp_register(&comp_kpb); } From e17acf75b3926b71271f645e2aabe70eff30f207 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:13:13 -0700 Subject: [PATCH 06/15] mixer: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/mixer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/mixer.c b/src/audio/mixer.c index 86fbe9a2b6e7..d2dc2e1aff34 100644 --- a/src/audio/mixer.c +++ b/src/audio/mixer.c @@ -445,9 +445,7 @@ struct comp_driver comp_mixer = { }, }; -void sys_comp_mixer_init(void); - -void sys_comp_mixer_init(void) +static void sys_comp_mixer_init(void) { comp_register(&comp_mixer); } From b70832c0a622a18687d24652356042884aa01b08 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:13:35 -0700 Subject: [PATCH 07/15] mux: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/mux.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/mux.c b/src/audio/mux.c index d0e369fabb17..0a7a261b31c9 100644 --- a/src/audio/mux.c +++ b/src/audio/mux.c @@ -97,9 +97,7 @@ struct comp_driver comp_mux = { }, }; -void sys_comp_mux_init(void); - -void sys_comp_mux_init(void) +static void sys_comp_mux_init(void) { comp_register(&comp_mux); } From 2fb4390bf503b90bfc2d84b53c0b26a27e71e2df Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:14:02 -0700 Subject: [PATCH 08/15] selector: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/selector.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/selector.c b/src/audio/selector.c index bbef436ffd43..77237525a240 100644 --- a/src/audio/selector.c +++ b/src/audio/selector.c @@ -516,10 +516,8 @@ struct comp_driver comp_selector = { }, }; -void sys_comp_selector_init(void); - /** \brief Initializes selector component. */ -void sys_comp_selector_init(void) +static void sys_comp_selector_init(void) { comp_register(&comp_selector); } From 967b37888e5990928f60f93975ea73f562ff65c4 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:14:17 -0700 Subject: [PATCH 09/15] src: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/src.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/src.c b/src/audio/src.c index 9fbc6fd51920..889830dc18f8 100644 --- a/src/audio/src.c +++ b/src/audio/src.c @@ -980,9 +980,7 @@ struct comp_driver comp_src = { }, }; -void sys_comp_src_init(void); - -void sys_comp_src_init(void) +static void sys_comp_src_init(void) { comp_register(&comp_src); } From bdcbd4931b144b3786fac3f5d762aa4641dd4cbc Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:14:40 -0700 Subject: [PATCH 10/15] switch: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/switch.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/switch.c b/src/audio/switch.c index 2d71ec7292b0..e3152b885052 100644 --- a/src/audio/switch.c +++ b/src/audio/switch.c @@ -97,9 +97,7 @@ struct comp_driver comp_switch = { }, }; -void sys_comp_switch_init(void); - -void sys_comp_switch_init(void) +static void sys_comp_switch_init(void) { comp_register(&comp_switch); } From 71ebf00c0afc89afe015cea0b31a1734b9bcc9ae Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:14:58 -0700 Subject: [PATCH 11/15] tone: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/tone.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/tone.c b/src/audio/tone.c index 6ff7e8e707fd..adc626566189 100644 --- a/src/audio/tone.c +++ b/src/audio/tone.c @@ -762,9 +762,7 @@ struct comp_driver comp_tone = { }, }; -void sys_comp_tone_init(void); - -void sys_comp_tone_init(void) +static void sys_comp_tone_init(void) { comp_register(&comp_tone); } From 5c00d196b647299e429d45dc47176d0a2ea5c2bb Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 21 Mar 2019 16:15:18 -0700 Subject: [PATCH 12/15] volume: make init function static Fixes checkpatch error that slipped in Signed-off-by: Curtis Malainey --- src/audio/volume.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/audio/volume.c b/src/audio/volume.c index e852b88a7242..65e5a39a0fe6 100644 --- a/src/audio/volume.c +++ b/src/audio/volume.c @@ -667,12 +667,10 @@ struct comp_driver comp_volume = { }, }; -void sys_comp_volume_init(void); - /** * \brief Initializes volume component. */ -void sys_comp_volume_init(void) +static void sys_comp_volume_init(void) { comp_register(&comp_volume); } From 07b959b897148298e5456a86b95641fc6d210f12 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Fri, 22 Mar 2019 14:30:45 +0100 Subject: [PATCH 13/15] include: add header for unit testing Signed-off-by: Janusz Jankowski --- src/include/sof/ut.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/include/sof/ut.h diff --git a/src/include/sof/ut.h b/src/include/sof/ut.h new file mode 100644 index 000000000000..4c60bcb02aa6 --- /dev/null +++ b/src/include/sof/ut.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Janusz Jankowski + */ + +#ifndef __INCLUDE_SOF_UT__ +#define __INCLUDE_SOF_UT__ + +/* UT_STATIC makes function unit-testable (non-static) when built for unit tests + */ +#ifdef CHECK +#define UT_STATIC +#else +#define UT_STATIC static +#endif + +#endif From 1ae04217f2a9625a4d2e2f92e7e3a393b9f989a3 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Fri, 22 Mar 2019 14:35:06 +0100 Subject: [PATCH 14/15] kpb: make init unit-testable Signed-off-by: Janusz Jankowski --- src/audio/kpb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 25f1e0a8efab..1acfa1dc2a8c 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -43,6 +43,7 @@ #include #include #include +#include static void kpb_event_handler(int message, void *cb_data, void *event_data); static int kpb_register_client(struct comp_data *kpb, struct kpb_client *cli); @@ -545,7 +546,7 @@ struct comp_driver comp_kpb = { }, }; -static void sys_comp_kpb_init(void) +UT_STATIC void sys_comp_kpb_init(void) { comp_register(&comp_kpb); } From 3b2a7a574c07ba58dbb9237c89d81e91d2355e4a Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Fri, 22 Mar 2019 14:35:23 +0100 Subject: [PATCH 15/15] mixer: make init unit-testable Signed-off-by: Janusz Jankowski --- src/audio/mixer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/mixer.c b/src/audio/mixer.c index d2dc2e1aff34..e710edac6a47 100644 --- a/src/audio/mixer.c +++ b/src/audio/mixer.c @@ -38,6 +38,7 @@ #include #include #include +#include #define trace_mixer(__e, ...) \ trace_event(TRACE_CLASS_MIXER, __e, ##__VA_ARGS__) @@ -445,7 +446,7 @@ struct comp_driver comp_mixer = { }, }; -static void sys_comp_mixer_init(void) +UT_STATIC void sys_comp_mixer_init(void) { comp_register(&comp_mixer); }