Changeset 333 for trunk/src


Ignore:
Timestamp:
Apr 21, 2011, 1:13:43 PM (14 years ago)
Author:
katerina
Message:

Add unit tests for IgnoreAdded/IgnoreDeleted configuration directives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_ignore.c

    r170 r333  
    3939#define FIL__ _("sh_ignore.c")
    4040
     41#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
     42
    4143struct sh_ignore_list {
    4244#ifdef HAVE_REGEX_H
     
    191193  return 0;
    192194}
    193 
    194 
    195 
    196 
    197 
    198 
     195#endif
     196
     197#ifdef SH_CUTEST
     198#include "CuTest.h"
     199
     200void Test_ignore_ok (CuTest *tc) {
     201#if defined(SH_WITH_CLIENT) || defined(SH_STANDALONE)
     202
     203  int ret;
     204
     205  CuAssertTrue(tc, NULL == sh_del_ign);
     206  CuAssertTrue(tc, NULL == sh_new_ign);
     207 
     208  ret = sh_ignore_add_del ("/var/log/foo/.*");
     209  CuAssertTrue(tc, 0 == ret);
     210  CuAssertPtrNotNull(tc, sh_del_ign);
     211
     212  ret = sh_ignore_chk_del ("/var/log/foo/test");
     213  CuAssertTrue(tc, S_TRUE == ret);
     214  CuAssertTrue(tc, NULL == sh_new_ign);
     215 
     216  ret = sh_ignore_chk_del ("/var/log/footest");
     217  CuAssertTrue(tc, S_FALSE == ret);
     218
     219  ret = sh_ignore_chk_del ("/my/var/log/footest");
     220  CuAssertTrue(tc, S_FALSE == ret);
     221
     222  sh_ignore_clean();
     223  CuAssertTrue(tc, NULL == sh_del_ign);
     224  CuAssertTrue(tc, NULL == sh_new_ign);
     225 
     226  ret = sh_ignore_add_new ("/var/log/foo/.*");
     227  CuAssertTrue(tc, 0 == ret);
     228  CuAssertPtrNotNull(tc, sh_new_ign);
     229  CuAssertTrue(tc, NULL == sh_del_ign);
     230
     231  ret = sh_ignore_chk_new ("/var/log/foo/test");
     232  CuAssertTrue(tc, S_TRUE == ret);
     233 
     234  ret = sh_ignore_chk_new ("/var/log/footest");
     235  CuAssertTrue(tc, S_FALSE == ret);
     236
     237  ret = sh_ignore_chk_new ("/my/var/log/footest");
     238  CuAssertTrue(tc, S_FALSE == ret);
     239
     240  sh_ignore_clean();
     241  CuAssertTrue(tc, NULL == sh_new_ign);
     242  CuAssertTrue(tc, NULL == sh_del_ign);
     243
     244#else
     245  (void) tc; /* fix compiler warning */
     246#endif
     247  return;
     248}
     249/* #ifdef SH_CUTEST */
     250#endif
     251
Note: See TracChangeset for help on using the changeset viewer.