2021-11-05 10:07:13

by Andriy Tryshnivskyy

[permalink] [raw]
Subject: [PATCH v1 2/2] iio: test: Add test for IIO_VAL_INT_64.

Add test for newly introduced type IIO_VAL_INT_64.

Signed-off-by: Andriy Tryshnivskyy <[email protected]>
---
Changes comparing v0 -> v1:
* add KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf)
* use ARRAY_SIZE(values)
* fixes according to Reverse Christmas Tree Format
* use constant UINT_MAX

drivers/iio/test/iio-test-format.c | 54 ++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)

diff --git a/drivers/iio/test/iio-test-format.c b/drivers/iio/test/iio-test-format.c
index b746d00bc0ea..237321436b83 100644
--- a/drivers/iio/test/iio-test-format.c
+++ b/drivers/iio/test/iio-test-format.c
@@ -197,12 +197,66 @@ static void iio_test_iio_format_value_multiple(struct kunit *test)
IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "1 -2 3 -4 5 \n");
}

+static void iio_test_iio_format_value_integer_64(struct kunit *test)
+{
+ int values[2];
+ s64 value;
+ char *buf;
+ int ret;
+
+ buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
+
+ value = 24;
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "24\n");
+
+ value = -24;
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-24\n");
+
+ value = 0;
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0\n");
+
+ value = UINT_MAX;
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "4294967295\n");
+
+ value = -((s64)UINT_MAX);
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-4294967295\n");
+
+ value = LLONG_MAX;
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "9223372036854775807\n");
+
+ value = LLONG_MIN;
+ values[0] = lower_32_bits(value);
+ values[1] = upper_32_bits(value);
+ ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
+ IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-9223372036854775808\n");
+}
+
static struct kunit_case iio_format_test_cases[] = {
KUNIT_CASE(iio_test_iio_format_value_integer),
KUNIT_CASE(iio_test_iio_format_value_fixedpoint),
KUNIT_CASE(iio_test_iio_format_value_fractional),
KUNIT_CASE(iio_test_iio_format_value_fractional_log2),
KUNIT_CASE(iio_test_iio_format_value_multiple),
+ KUNIT_CASE(iio_test_iio_format_value_integer_64),
{}
};

--
2.17.1


2021-11-05 20:33:42

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 2/2] iio: test: Add test for IIO_VAL_INT_64.

Hi Andriy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on 7d2a07b769330c34b4deabeed939325c77a7ec2f]

url: https://github.com/0day-ci/linux/commits/Andriy-Tryshnivskyy/iio-test-Add-test-for-IIO_VAL_INT_64/20211105-180624
base: 7d2a07b769330c34b4deabeed939325c77a7ec2f
config: arc-buildonly-randconfig-r002-20211105 (attached as .config)
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/679e11158271ed8c6219060b06dca25dce946859
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andriy-Tryshnivskyy/iio-test-Add-test-for-IIO_VAL_INT_64/20211105-180624
git checkout 679e11158271ed8c6219060b06dca25dce946859
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/iio/test/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

drivers/iio/test/iio-test-format.c: In function 'iio_test_iio_format_value_integer_64':
>> drivers/iio/test/iio-test-format.c:213:37: error: 'IIO_VAL_INT_64' undeclared (first use in this function); did you mean 'IIO_VAL_INT'?
213 | ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
| ^~~~~~~~~~~~~~
| IIO_VAL_INT
drivers/iio/test/iio-test-format.c:213:37: note: each undeclared identifier is reported only once for each function it appears in


vim +213 drivers/iio/test/iio-test-format.c

199
200 static void iio_test_iio_format_value_integer_64(struct kunit *test)
201 {
202 int values[2];
203 s64 value;
204 char *buf;
205 int ret;
206
207 buf = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
208 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
209
210 value = 24;
211 values[0] = lower_32_bits(value);
212 values[1] = upper_32_bits(value);
> 213 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
214 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "24\n");
215
216 value = -24;
217 values[0] = lower_32_bits(value);
218 values[1] = upper_32_bits(value);
219 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
220 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-24\n");
221
222 value = 0;
223 values[0] = lower_32_bits(value);
224 values[1] = upper_32_bits(value);
225 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
226 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "0\n");
227
228 value = UINT_MAX;
229 values[0] = lower_32_bits(value);
230 values[1] = upper_32_bits(value);
231 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
232 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "4294967295\n");
233
234 value = -((s64)UINT_MAX);
235 values[0] = lower_32_bits(value);
236 values[1] = upper_32_bits(value);
237 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
238 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-4294967295\n");
239
240 value = LLONG_MAX;
241 values[0] = lower_32_bits(value);
242 values[1] = upper_32_bits(value);
243 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
244 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "9223372036854775807\n");
245
246 value = LLONG_MIN;
247 values[0] = lower_32_bits(value);
248 values[1] = upper_32_bits(value);
249 ret = iio_format_value(buf, IIO_VAL_INT_64, ARRAY_SIZE(values), values);
250 IIO_TEST_FORMAT_EXPECT_EQ(test, buf, ret, "-9223372036854775808\n");
251 }
252

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (4.16 kB)
.config.gz (25.98 kB)
Download all attachments