Skip to content

Instantly share code, notes, and snippets.

@juniorz
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juniorz/1160193c118f1f578f05 to your computer and use it in GitHub Desktop.
Save juniorz/1160193c118f1f578f05 to your computer and use it in GitHub Desktop.
Running tests for golang crypto/otr package

libotr and crypto/otr config instructions

If you want to run crypto/otr tests, run

setup-libotr2-3.1.0
setup-crypto-otr

If you want to build all versions of libotr (to run its test_suite/otr_c_client), run

setup-libotr2-3.0.0
setup-libotr2-3.1.0
setup-libotr2-3.2.0
setup-libotr3-4.0.0

There's also a setup for the latest version, for completeness

setup-libotr3-4.1.0
#!/bin/bash
set -xeu
# Change if you want
OTR_DIR=/tmp/otr
mkdir -p $OTR_DIR
git clone https://github.com/golang/crypto $OTR_DIR/golang-crypto
cd $OTR_DIR/golang-crypto/otr
gcc -I$OTR_DIR/libotr2-3.1.0/include/libotr -L$OTR_DIR/libotr2-3.1.0/lib \
-v -lotr -o /tmp/a.out libotr_test_helper.c
cat <<EOF | git apply --ignore-space-change --ignore-whitespace -v -
diff --git a/otr/otr_test.go b/otr/otr_test.go
index 1e2bbfc..7f29172 100644
--- a/otr/otr_test.go
+++ b/otr/otr_test.go
@@ -300,7 +300,7 @@ func TestAgainstLibOTR(t *testing.T) {
// This test requires otr.c.test to be built as /tmp/a.out.
// If enabled, this tests runs forever performing OTR handshakes in a
// loop.
- return
+ // return
alicePrivateKey, _ := hex.DecodeString(alicePrivateKeyHex)
var alice Conversation
EOF
set +xeu
cat <<EOM
# ----------------------------------------------------------------------------
# run the tests with
# ----------------------------------------------------------------------------
cd $OTR_DIR/golang-crypto/otr
DYLD_LIBRARY_PATH=$OTR_DIR/libotr2-3.1.0/lib go test -v
EOM
#!/bin/bash
set -xeu
# Change if you want
OTR_DIR=/tmp/otr
mkdir -p $OTR_DIR
brew install automake libtool libgcrypt libgpg-error
[ -e $OTR_DIR/libotr ] || git clone git://git.otr.im/libotr.git $OTR_DIR/libotr
cd $OTR_DIR/libotr
git co 63802c9 -B v2-3.0.0
git clean -fd
autoreconf -s -i
./configure --with-pic --prefix=$OTR_DIR/libotr2-3.0.0
make install
#!/bin/bash
set -xeu
# Change if you want
OTR_DIR=/tmp/otr
mkdir -p $OTR_DIR
brew install automake libtool libgcrypt libgpg-error
[ -e $OTR_DIR/libotr ] || git clone git://git.otr.im/libotr.git $OTR_DIR/libotr
cd $OTR_DIR/libotr
git co 5839381 -B v2-3.1.0
autoreconf -s -i
./configure --with-pic --prefix=$OTR_DIR/libotr2-3.1.0
make install
#!/bin/bash
set -xeu
# Change if you want
OTR_DIR=/tmp/otr
mkdir -p $OTR_DIR
brew install automake libtool libgcrypt libgpg-error
[ -e $OTR_DIR/libotr ] || git clone git://git.otr.im/libotr.git $OTR_DIR/libotr
cd $OTR_DIR/libotr
git co 2deecec -B v2-3.2.0
autoreconf -s -i
./configure --with-pic --prefix=$OTR_DIR/libotr2-3.2.0
make install
#!/bin/bash
set -xeu
# Change if you want
OTR_DIR=/tmp/otr
mkdir -p $OTR_DIR
brew install automake libtool libgcrypt libgpg-error
[ -e $OTR_DIR/libotr ] || git clone git://git.otr.im/libotr.git $OTR_DIR/libotr
cd $OTR_DIR/libotr
git co 31b6e9f -B v3-4.0.0
autoreconf -s -i
./configure --with-pic --prefix=$OTR_DIR/libotr3-4.0.0
make install
#!/bin/bash
set -xeu
# Change if you want
OTR_DIR=/tmp/otr
mkdir -p $OTR_DIR
brew install automake libtool libgcrypt libgpg-error
[ -e $OTR_DIR/libotr ] || git clone git://git.otr.im/libotr.git $OTR_DIR/libotr
cd $OTR_DIR/libotr
git co c9710e9 -B v3-4.1.0
./bootstrap
./configure --with-pic --prefix=$OTR_DIR/libotr3-4.1.0
make install
@olabini
Copy link

olabini commented Jul 7, 2015

Nice stuff! Suffice to say, the setup_crypto_otr only works with OS X in the current format. Changing it to run on Linux shouldn't be too bad though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment