~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/afmongodb/libmongo-client/tests/unit/mongo/wire/cmd_kill_cursors.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "test.h"
 
2
#include "tap.h"
 
3
#include "mongo-wire.h"
 
4
 
 
5
#include <string.h>
 
6
 
 
7
void
 
8
test_mongo_wire_cmd_kill_cursors (void)
 
9
{
 
10
  mongo_packet *p;
 
11
 
 
12
  mongo_packet_header hdr;
 
13
  const guint8 *data;
 
14
  gint32 data_size;
 
15
 
 
16
  gint32 pos, n = 0;
 
17
  gint64 c1 = 9876543210, c2 = 1234567890;
 
18
 
 
19
  ok (mongo_wire_cmd_kill_cursors (1, 0) == NULL,
 
20
      "mongo_wire_cmd_kill_cursors() should fail with zero cursors");
 
21
  ok (mongo_wire_cmd_kill_cursors (1, -1) == NULL,
 
22
      "mongo_wire_cmd_kill_cursors() should fail with negative amount of "
 
23
      "cursors");
 
24
  ok ((p = mongo_wire_cmd_kill_cursors (1, 2, c1, c2)) != NULL,
 
25
      "mongo_wire_cmd_kill_cursors() works");
 
26
 
 
27
  /* Verify the header */
 
28
  mongo_wire_packet_get_header (p, &hdr);
 
29
  cmp_ok ((data_size = mongo_wire_packet_get_data (p, &data)), "!=", -1,
 
30
          "Packet data size looks fine");
 
31
  cmp_ok (hdr.length, "==", sizeof (mongo_packet_header) + data_size,
 
32
          "Packet header length is OK");
 
33
  cmp_ok (hdr.id, "==", 1, "Packet request ID is ok");
 
34
  cmp_ok (hdr.resp_to, "==", 0, "Packet reply ID is ok");
 
35
 
 
36
  /*
 
37
   * Test the request contents
 
38
   */
 
39
  c1 = c2 = 0;
 
40
  /* pos = zero + n */
 
41
  pos = sizeof (gint32) + sizeof (n);
 
42
 
 
43
  memcpy (&n, data + sizeof (gint32), sizeof (gint32));
 
44
  memcpy (&c1, data + pos, sizeof (c1));
 
45
  memcpy (&c2, data + pos + sizeof (c1), sizeof (c2));
 
46
 
 
47
  n = GINT32_FROM_LE (n);
 
48
  c1 = GINT64_FROM_LE (c1);
 
49
  c2 = GINT64_FROM_LE (c2);
 
50
 
 
51
  ok (n == 2, "Number of cursors are OK");
 
52
  ok (c1 == 9876543210, "First cursor is OK");
 
53
  ok (c2 == 1234567890, "Second cursor is OK");
 
54
 
 
55
  mongo_wire_packet_free (p);
 
56
}
 
57
 
 
58
RUN_TEST (10, mongo_wire_cmd_kill_cursors);