From 3f68c3e171fc5f572f5a7dbca685aeaa66f741a5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Sep 2015 19:00:01 +0000 Subject: -test skeleton --- src/scalarproduct/Makefile.am | 11 ++++- src/scalarproduct/test_ecc_scalarproduct.c | 66 ++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 src/scalarproduct/test_ecc_scalarproduct.c (limited to 'src/scalarproduct') diff --git a/src/scalarproduct/Makefile.am b/src/scalarproduct/Makefile.am index c09e38393..57df0e840 100644 --- a/src/scalarproduct/Makefile.am +++ b/src/scalarproduct/Makefile.am @@ -102,7 +102,16 @@ check_SCRIPTS = \ test_scalarproduct_negative.sh \ test_scalarproduct_negativezero.sh +check_PROGRAMS = \ + test_ecc_scalarproduct + if ENABLE_TEST_RUN AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; - TESTS = $(check_SCRIPTS) + TESTS = $(check_SCRIPTS) $(check_PROGRAMS) endif + + +test_ecc_scalarproduct_SOURCES = \ + test_ecc_scalarproduct.c +test_ecc_scalarproduct_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/scalarproduct/test_ecc_scalarproduct.c b/src/scalarproduct/test_ecc_scalarproduct.c new file mode 100644 index 000000000..7e0f90eae --- /dev/null +++ b/src/scalarproduct/test_ecc_scalarproduct.c @@ -0,0 +1,66 @@ +/* + This file is part of GNUnet. + Copyright (C) 2015 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ +/** + * @file util/test_ecc_scalarproduct.c + * @brief testcase for math behind ECC SP calculation + * @author Christian Grothoff + */ +#include "platform.h" +#include "gnunet_util_lib.h" +#include + + +/** + * Perform SP calculation. + * + * @param avec 0-terminated vector of Alice's values + * @param bvec 0-terminated vector of Bob's values + * @return avec * bvec + */ +static int +test_sp (const unsigned int *avec, + const unsigned int *bvec) +{ + return -1; +} + + +int +main (int argc, char *argv[]) +{ + static unsigned int v11[] = { 1, 1, 0 }; + static unsigned int v22[] = { 2, 2, 0 }; + static unsigned int v35[] = { 3, 5, 0 }; + static unsigned int v24[] = { 2, 4, 0 }; + + GNUNET_log_setup ("test-ecc-scalarproduct", + "WARNING", + NULL); + GNUNET_assert ( 2 == test_sp (v11, v11)); + GNUNET_assert ( 4 == test_sp (v22, v11)); + GNUNET_assert ( 8 == test_sp (v35, v11)); + GNUNET_assert (26 == test_sp (v35, v24)); + GNUNET_assert (26 == test_sp (v24, v35)); + GNUNET_assert (16 == test_sp (v22, v35)); + return 0; +} + +/* end of test_ecc_scalarproduct.c */ -- cgit v1.2.3