File: build

package info (click to toggle)
leveldb 1.23-6
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,572 kB
  • sloc: cpp: 20,432; ansic: 623; sh: 69; makefile: 49
file content (69 lines) | stat: -rw-r--r-- 1,673 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
# autopkgtest check: Builds a small application against leveldb, checking
# if it compiles, links and runs successfully.
# Author: Alessio Treglia <alessio@debian.org>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR

if [ -n "$DEB_HOST_MULTIARCH" ]; then
    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
fi

cat <<EOF > build_test.cpp
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>

#include "leveldb/db.h"

using namespace std;

int main(int argc, char **argv)
{
    leveldb::DB *db;
    leveldb::Options opts;
    leveldb::ReadOptions r_opts;
    leveldb::WriteOptions w_opts;
    std::string value;

    opts.create_if_missing = true;
    // Create a new db
    leveldb::Status s = leveldb::DB::Open(opts,
					   "./build_test_db",
					   &db);
    assert (s.ok() == true);
    // Check if the db is empty
    s = db->Get(r_opts, "test_key1", &value);
    assert (s.IsNotFound() == true);
    // Add such new key to the db
    s = db->Put(w_opts, "test_key1", "test_value1");
    assert (s.ok() == true);
    // Get the new key
    s = db->Get(r_opts, "test_key1", &value);
    assert (s.ok() == true);
    // Check the return value
    assert (value.compare("test_value1") == 0);
    // Delete the key
    s = db->Delete(w_opts, "test_key1");
    assert (s.ok() == true);
    // Check if the deletion's gone well
    s = db->Get(r_opts, "test_key1", &value);
    assert (s.IsNotFound() == true);

    // Close the db
    delete db;

    return 0;
}
EOF

${CROSS_COMPILE}g++ -o build_test build_test.cpp -pthread -lleveldb -lsnappy
echo "build: OK"
[ -x build_test ]
./build_test
echo "run: OK"