diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-16 20:29:10 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-16 20:29:10 +0000 |
commit | eec0e5088ec9437f5c0cf9d3ffef87603ad2777a (patch) | |
tree | 539ee940e481ba9d5174c44c227680c6bf048efb /src/scalarproduct | |
parent | 608eb4de09b1033c24ee5b6ad095399e375ac511 (diff) | |
download | gnunet-eec0e5088ec9437f5c0cf9d3ffef87603ad2777a.tar.gz gnunet-eec0e5088ec9437f5c0cf9d3ffef87603ad2777a.zip |
complete testcase template, currently functionally blocked by two issues in the testbed profiler
renamed a couple of cariables
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 22 | ||||
-rwxr-xr-x | src/scalarproduct/test_scalarproduct.sh | 26 |
2 files changed, 30 insertions, 18 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index e10e16968..bfa6c8401 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -1708,7 +1708,7 @@ handle_client_request (void *cls, | |||
1708 | // get our peer ID | 1708 | // get our peer ID |
1709 | memcpy (&session->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity)); | 1709 | memcpy (&session->peer, &msg->peer, sizeof (struct GNUNET_PeerIdentity)); |
1710 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1710 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1711 | _ ("Creating new tunnel to for session with key %s.\n"), | 1711 | _ ("Creating new tunnel for session with key %s.\n"), |
1712 | GNUNET_h2s (&session->key)); | 1712 | GNUNET_h2s (&session->key)); |
1713 | session->tunnel = GNUNET_MESH_tunnel_create (my_mesh, session, | 1713 | session->tunnel = GNUNET_MESH_tunnel_create (my_mesh, session, |
1714 | &session->peer, | 1714 | &session->peer, |
@@ -1872,9 +1872,9 @@ compute_scalar_product (struct ServiceSession * session) | |||
1872 | uint32_t count; | 1872 | uint32_t count; |
1873 | gcry_mpi_t t; | 1873 | gcry_mpi_t t; |
1874 | gcry_mpi_t u; | 1874 | gcry_mpi_t u; |
1875 | gcry_mpi_t utick; | 1875 | gcry_mpi_t u_prime; |
1876 | gcry_mpi_t p; | 1876 | gcry_mpi_t p; |
1877 | gcry_mpi_t ptick; | 1877 | gcry_mpi_t p_prime; |
1878 | gcry_mpi_t tmp; | 1878 | gcry_mpi_t tmp; |
1879 | unsigned int i; | 1879 | unsigned int i; |
1880 | 1880 | ||
@@ -1902,12 +1902,12 @@ compute_scalar_product (struct ServiceSession * session) | |||
1902 | gcry_mpi_release (tmp); | 1902 | gcry_mpi_release (tmp); |
1903 | 1903 | ||
1904 | //calculate U' | 1904 | //calculate U' |
1905 | utick = gcry_mpi_new (0); | 1905 | u_prime = gcry_mpi_new (0); |
1906 | tmp = compute_square_sum (session->r_prime, count); | 1906 | tmp = compute_square_sum (session->r_prime, count); |
1907 | gcry_mpi_sub (utick, utick, tmp); | 1907 | gcry_mpi_sub (u_prime, u_prime, tmp); |
1908 | 1908 | ||
1909 | GNUNET_assert (p = gcry_mpi_new (0)); | 1909 | GNUNET_assert (p = gcry_mpi_new (0)); |
1910 | GNUNET_assert (ptick = gcry_mpi_new (0)); | 1910 | GNUNET_assert (p_prime = gcry_mpi_new (0)); |
1911 | 1911 | ||
1912 | // compute P | 1912 | // compute P |
1913 | decrypt_element (session->s, session->s, my_mu, my_lambda, my_n, my_nsquare); | 1913 | decrypt_element (session->s, session->s, my_mu, my_lambda, my_n, my_nsquare); |
@@ -1918,16 +1918,16 @@ compute_scalar_product (struct ServiceSession * session) | |||
1918 | gcry_mpi_add (p, p, u); | 1918 | gcry_mpi_add (p, p, u); |
1919 | 1919 | ||
1920 | // compute P' | 1920 | // compute P' |
1921 | gcry_mpi_add (ptick, session->s_prime, t); | 1921 | gcry_mpi_add (p_prime, session->s_prime, t); |
1922 | gcry_mpi_add (ptick, ptick, utick); | 1922 | gcry_mpi_add (p_prime, p_prime, u_prime); |
1923 | 1923 | ||
1924 | gcry_mpi_release (t); | 1924 | gcry_mpi_release (t); |
1925 | gcry_mpi_release (u); | 1925 | gcry_mpi_release (u); |
1926 | gcry_mpi_release (utick); | 1926 | gcry_mpi_release (u_prime); |
1927 | 1927 | ||
1928 | // compute product | 1928 | // compute product |
1929 | gcry_mpi_sub (p, p, ptick); | 1929 | gcry_mpi_sub (p, p, p_prime); |
1930 | gcry_mpi_release (ptick); | 1930 | gcry_mpi_release (p_prime); |
1931 | tmp = gcry_mpi_set_ui (tmp, 2); | 1931 | tmp = gcry_mpi_set_ui (tmp, 2); |
1932 | gcry_mpi_div (p, NULL, p, tmp, 0); | 1932 | gcry_mpi_div (p, NULL, p, tmp, 0); |
1933 | 1933 | ||
diff --git a/src/scalarproduct/test_scalarproduct.sh b/src/scalarproduct/test_scalarproduct.sh index 0ac0d82fc..29f78ef9b 100755 --- a/src/scalarproduct/test_scalarproduct.sh +++ b/src/scalarproduct/test_scalarproduct.sh | |||
@@ -1,21 +1,33 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # compute a simple scalar product | ||
2 | 3 | ||
3 | #necessary to make the testing prefix deterministic, so we can access the config files | 4 | #necessary to make the testing prefix deterministic, so we can access the config files |
4 | GNUNET_TESTING_PREFIX=/tmp/test-scalarproduct`date +%H%M%S` | 5 | PREFIX=/tmp/test-scalarproduct`date +%H%M%S` |
5 | CFGALICE="-c $GNUNET_TESTING_PREFIX/0/config" | ||
6 | CFGBOB="-c $GNUNET_TESTING_PREFIX/1/config" | ||
7 | 6 | ||
8 | ../testbed/gnunet-testbed-profiler -c test_scalarproduct.conf -p 2 2>gnunet_error.log & | 7 | #where can we find the peers config files? |
8 | CFGALICE="-c $PREFIX/0/config" | ||
9 | CFGBOB="-c $PREFIX/1/config" | ||
10 | |||
11 | #log at which loglevel? | ||
12 | LOG="-L ERROR" | ||
13 | |||
14 | #launch two peers in line topology | ||
15 | GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler $LOG -c test_scalarproduct.conf -p 2 2>gnunet_error.log & | ||
9 | sleep 5 | 16 | sleep 5 |
10 | 17 | ||
18 | #get bob's peer ID, necessary for alice | ||
11 | PEERIDBOB=`gnunet-peerinfo -qs $CFGB` | 19 | PEERIDBOB=`gnunet-peerinfo -qs $CFGB` |
20 | |||
21 | #payload for this test on both sides | ||
12 | INPUTALICE="-k AAAA -e 10,10,10" | 22 | INPUTALICE="-k AAAA -e 10,10,10" |
13 | INPUTBOB="-k AAAA -e 10,10,10" | 23 | INPUTBOB="-k AAAA -e 10,10,10" |
14 | EXPECTED="2C0" | ||
15 | 24 | ||
16 | gnunet-scalarproduct $CFGBOB $INPUTBOB | 25 | echo "gnunet-scalarproduct $LOG $CFGBOB $INPUTBOB &" |
17 | RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>client_error.log` | 26 | echo "gnunet-scalarproduct $LOG $CFGALICE $INPUTALICE -p $PEERIDBOB -L ERROR" |
27 | gnunet-scalarproduct $LOG $CFGBOB $INPUTBOB 2>bob_error.log & | ||
28 | RESULT=`gnunet-scalarproduct $LOG $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice_error.log` | ||
18 | 29 | ||
30 | EXPECTED="12C" | ||
19 | if [ "$RESULT" == "$EXPECTED" ] | 31 | if [ "$RESULT" == "$EXPECTED" ] |
20 | then | 32 | then |
21 | echo "OK" | 33 | echo "OK" |