add env script, and (stupid) draft tests

This commit is contained in:
2024-01-03 19:09:17 +01:00
parent a41ca50404
commit 2bab5c9d2c
3 changed files with 81 additions and 2 deletions

46
test/bitops-test.c Normal file
View File

@@ -0,0 +1,46 @@
/* bits.c - bitops testing.
*
* Copyright (C) 2024 Bruno Raoult ("br")
* Licensed under the GNU General Public License v3.0 or later.
* Some rights reserved. See COPYING.
*
* You should have received a copy of the GNU General Public License along with this
* program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
*
* SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "br.h"
#include "bitops.h"
// #include "cutest/CuTest.h"
static void test_popcount()
{
u32 t32[] = { 0x0, 0x88000101, 0xffffffff };
u64 t64[] = { 0x0ll, 0x8880000000000101LL, 0xffffffffffffffffll };
for (uint i = 0; i < sizeof(t32); ++i) {
printf("popcount 32 (%#x): ", t32[i]);
# ifdef ___popcount32_native
printf("native:%d ", ___popcount32_native(t32[i]));
# endif
printf("emulated:%d\n", ___popcount_emulated(t32[i]));
}
for (uint i = 0; i < sizeof(t64); ++i) {
printf("popcount 64 (%#lx): ", t64[i]);
# ifdef ___popcount64_native
printf("native:%d ", ___popcount64_native(t64[i]));
# endif
printf("emulated:%d\n", ___popcount_emulated(t64[i]));
}
}
int main()
{
test_popcount();
exit(0);
}

View File

@@ -1,6 +1,9 @@
#include <stdio.h>
#include "bits.h"
#include <stdlib.h>
#include "br.h"
#include "pool.h"
#include "debug.h"
struct d {
u16 data1;
@@ -19,7 +22,7 @@ int main(int ac, char**av)
char ccur='z';
struct d *elt;
debug_init(3);
debug_init(3, stderr, true);
log_f(1, "%s: sizeof(d)=%lu sizeof(*d)=%lu off=%lu\n", *av, sizeof(elt),
sizeof(*elt), offsetof(struct d, list));