Ignore:
Timestamp:
Sep 21, 2009, 8:23:56 PM (15 years ago)
Author:
katerina
Message:

Code to track down originating site for ticket #163.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cutest_slib.c

    r169 r248  
    55#include "CuTest.h"
    66#include "samhain.h"
     7
     8void Test_sl_stale (CuTest *tc) {
     9
     10  extern int get_the_fd (SL_TICKET ticket);
     11
     12  int       fd1, fd2, ret, line, val;
     13  SL_TICKET tfd1, tfd2;
     14  char *    err1;
     15  char      err2[128];
     16
     17  line = __LINE__; tfd1 = sl_open_read(__FILE__, __LINE__, "/etc/group", SL_NOPRIV);
     18  CuAssertTrue(tc, tfd1 > 0);
     19
     20  fd1 = get_the_fd(tfd1);
     21  CuAssertTrue(tc, fd1 >= 0);
     22
     23  ret = close(fd1);
     24  CuAssertTrue(tc, ret == 0);
     25
     26  tfd2 = sl_open_read(__FILE__, __LINE__, "/etc/group", SL_NOPRIV);
     27  CuAssertTrue(tc, tfd2 > 0);
     28  CuAssertTrue(tc, tfd2 != tfd1);
     29
     30  fd2 = get_the_fd(tfd2);
     31  CuAssertIntEquals(tc, fd1, fd2);
     32
     33  err1 = sl_check_stale();
     34  CuAssertTrue(tc, err1 != NULL);
     35
     36  sl_snprintf(err2, sizeof(err2),
     37              "stale handle, %s, %d", __FILE__, line);
     38  val = strcmp(err1, err2);
     39  CuAssertIntEquals(tc, 0, val);
     40}
    741
    842void Test_sl_snprintf (CuTest *tc) {
Note: See TracChangeset for help on using the changeset viewer.