~yeban/libmemcached/todo-host.c

« back to all changes in this revision

Viewing changes to tests/mem_functions.c

  • Committer: Brian Aker
  • Date: 2011-03-25 00:48:22 UTC
  • mfrom: (928.1.4 libmemcached-trunk)
  • Revision ID: brian@tangent.org-20110325004822-71q9m50jhq1bvugx
Merge fixes from build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
784
784
 
785
785
static test_return_t memcached_server_cursor_test(memcached_st *memc)
786
786
{
787
 
  char context[8];
788
 
  strcpy(context, "foo bad");
 
787
  char context[10];
 
788
  strncpy(context, "foo bad", sizeof(context));
789
789
  memcached_server_fn callbacks[1];
790
790
 
791
791
  callbacks[0]= server_function;
4001
4001
 
4002
4002
    /* Test a long key for failure */
4003
4003
    /* TODO, extend test to determine based on setting, what result should be */
4004
 
    strcpy(long_key, "Thisismorethentheallottednumberofcharacters");
 
4004
    strncpy(long_key, "Thisismorethentheallottednumberofcharacters", sizeof(long_key));
4005
4005
    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
4006
4006
    //test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
4007
4007
    test_true(rc == MEMCACHED_SUCCESS);
4008
4008
 
4009
4009
    /* Now test a key with spaces (which will fail from long key, since bad key is not set) */
4010
 
    strcpy(long_key, "This is more then the allotted number of characters");
 
4010
    strncpy(long_key, "This is more then the allotted number of characters", sizeof(long_key));
4011
4011
    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
4012
4012
    test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
4013
4013
 
4015
4015
    rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, 1);
4016
4016
    test_true(rc == MEMCACHED_SUCCESS);
4017
4017
 
4018
 
    strcpy(long_key, "dog cat");
 
4018
    strncpy(long_key, "dog cat", sizeof(long_key));
4019
4019
    rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_PREFIX_KEY, long_key);
4020
4020
    test_true(rc == MEMCACHED_BAD_KEY_PROVIDED);
4021
4021
  }
5967
5967
  /* put failure limit to 1 */
5968
5968
  rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, 1);
5969
5969
  assert(rc == MEMCACHED_SUCCESS);
 
5970
 
5970
5971
  /* Put a retry timeout to effectively activate failure_limit effect */
5971
5972
  rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 1);
5972
5973
  assert(rc == MEMCACHED_SUCCESS);
 
5974
 
5973
5975
  /* change behavior that triggers memcached_quit()*/
5974
5976
  rc= memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
5975
5977
  assert(rc == MEMCACHED_SUCCESS);