Commit e9caba55 authored by unknown's avatar unknown

Maria - WL#3134 Key cache to Page cache conversion

Moving the test_pagecache_ tests from mysys to unittest/mysys.
Means fixing includes to work with the new directory, some Makefile.am
editing, replacing memset() with bfill().
test_page_cache_*.c renamed to mf_pagecache_*-t.c (-t is the standard
suffix for tests in the mytap protocol).
Also added plan() and exit_status() calls to tests.
Sanja, I put some TODOs for you at the start of mf_pagecache_*.c


unittest/mysys/test_file.h:
  Rename: mysys/test_file.h -> unittest/mysys/test_file.h
mysys/Makefile.am:
  pagecache test files move to top/unittest/mysys
mysys/mf_pagecache.c:
  my_bit.h needed to compile.
unittest/mysys/Makefile.am:
  INCLUDES is a better place for includes than AM_CPPFLAGS (the latter
  get overriden by prog_CPPFLAGS, which is not desirable here).
  Adding pagecache's test programs (moved from mysys);
  test_pagecache_* has been renamed to mf_pagecache*-t
  (-t is the required suffix for test executables in the mytap framework).
unittest/mysys/mf_pagecache_consist.c:
  fixing includes to work with the new directory.
  The test must return an exit code informing if any part failed.
  TODOs for Sanja.
unittest/mysys/mf_pagecache_single.c:
  fixing includes to work with new directory.
  adding a plan() to account for the number of tests.
  Adding exit_status() to tell how many tests failed.
  memset() was giving a compilation warning (implicit declaration etc),
  properly due to me removing stdio.h etc, so I replaced it with bfill().
  TODOs for Sanja.
unittest/mysys/test_file.c:
  moved from mysys (piece of the page cache tests) and includes fixed.
parent 760493f8
......@@ -130,61 +130,6 @@ test_base64$(EXEEXT): base64.c $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN ./test_base64.c $(LDADD) $(LIBS)
$(RM) -f ./test_base64.c
test_mf_pagecache.o: mf_pagecache.c ../include/pagecache.h $(LIBRARIES)
$(CP) $(srcdir)/mf_pagecache.c test_mf_pagecache.c
$(COMPILE) $(FLAGS) -DPAGECACHE_DEBUG -DEXTRA_DEBUG -c test_mf_pagecache.c
test_file.o: test_file.c test_file.h
$(COMPILE) $(FLAGS) -DPAGECACHE_DEBUG -DEXTRA_DEBUG -c test_file.c
test_pagecache_single1k$(EXEEXT): test_pagecache_single.c test_mf_pagecache.o ../unittest/mytap/tap.o test_file.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DPAGE_SIZE=1024 -DEXTRA_DEBUG $(srcdir)/test_pagecache_single.c test_mf_pagecache.o ../unittest/mytap/tap.o test_file.o $(LDADD) $(LIBS)
test_pagecache_single8k$(EXEEXT): test_pagecache_single.c test_mf_pagecache.o ../unittest/mytap/tap.o test_file.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DPAGE_SIZE=8192 -DEXTRA_DEBUG $(srcdir)/test_pagecache_single.c test_mf_pagecache.o ../unittest/mytap/tap.o test_file.o $(LDADD) $(LIBS)
test_pagecache_single64k$(EXEEXT): test_pagecache_single.c test_mf_pagecache.o ../unittest/mytap/tap.o test_file.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DPAGE_SIZE=65536 -DEXTRA_DEBUG $(srcdir)/test_pagecache_single.c test_mf_pagecache.o ../unittest/mytap/tap.o test_file.o $(LDADD) $(LIBS)
test_pagecache_single: test_pagecache_single1k$(EXEEXT) test_pagecache_single8k$(EXEEXT) test_pagecache_single64k$(EXEEXT)
./test_pagecache_single64k$(EXEEXT)
./test_pagecache_single8k$(EXEEXT)
./test_pagecache_single1k$(EXEEXT)
test_pagecache_consist1k$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DPAGE_SIZE=1024 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist64k$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DPAGE_SIZE=65536 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist1kHC$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DTEST_HIGH_CONCURENCY -DPAGE_SIZE=1024 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist64kHC$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DTEST_HIGH_CONCURENCY -DPAGE_SIZE=65536 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist1kRD$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DTEST_READERS -DPAGE_SIZE=1024 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist64kRD$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DTEST_READERS -DPAGE_SIZE=65536 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist1kWR$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DTEST_WRITERS -DPAGE_SIZE=1024 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist64kWR$(EXEEXT): test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN -DPAGECACHE_DEBUG -DTEST_WRITERS -DPAGE_SIZE=65536 -DEXTRA_DEBUG $(srcdir)/test_pagecache_consist.c test_mf_pagecache.o ../unittest/mytap/tap.o $(LDADD) $(LIBS)
test_pagecache_consist: test_pagecache_consist1k$(EXEEXT) test_pagecache_consist64k$(EXEEXT) test_pagecache_consist1kHC$(EXEEXT) test_pagecache_consist64kHC$(EXEEXT) test_pagecache_consist1kRD$(EXEEXT) test_pagecache_consist64kRD$(EXEEXT) test_pagecache_consist1kWR$(EXEEXT) test_pagecache_consist64kWR$(EXEEXT)
./test_pagecache_consist1k$(EXEEXT)
./test_pagecache_consist64k$(EXEEXT)
./test_pagecache_consist1kHC$(EXEEXT)
./test_pagecache_consist64kHC$(EXEEXT)
./test_pagecache_consist1kRD$(EXEEXT)
./test_pagecache_consist64kRD$(EXEEXT)
./test_pagecache_consist1kWR$(EXEEXT)
./test_pagecache_consist64kWR$(EXEEXT)
# Don't update the files from bitkeeper
%::SCCS/s.%
......@@ -45,6 +45,8 @@
#include <m_string.h>
#include <errno.h>
#include <stdarg.h>
#include <my_bit.h>
/*
Some compilation flags have been added specifically for this module
......
INCLUDES = @ZLIB_INCLUDES@ -I$(top_builddir)/include \
-I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
AM_CPPFLAGS = @ZLIB_INCLUDES@ -I$(top_builddir)/include
AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/unittest/mytap
LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/mysys/libmysys.a \
$(top_builddir)/dbug/libdbug.a \
$(top_builddir)/strings/libmystrings.a
noinst_PROGRAMS = bitmap-t base64-t my_atomic-t
noinst_PROGRAMS = bitmap-t base64-t my_atomic-t \
mf_pagecache_single_1k-t mf_pagecache_single_8k-t \
mf_pagecache_single_64k-t \
mf_pagecache_consist_1k-t mf_pagecache_consist_64k-t \
mf_pagecache_consist_1kHC-t mf_pagecache_consist_64kHC-t \
mf_pagecache_consist_1kRD-t mf_pagecache_consist_64kRD-t \
mf_pagecache_consist_1kWR-t mf_pagecache_consist_64kWR-t
# tests for mysys/mf_pagecache.c
mf_pagecache_single_src = mf_pagecache_single.c $(top_srcdir)/mysys/mf_pagecache.c test_file.c
mf_pagecache_consist_src = mf_pagecache_consist.c $(top_srcdir)/mysys/mf_pagecache.c test_file.c
mf_pagecache_common_cppflags = -DEXTRA_DEBUG -DPAGECACHE_DEBUG -DMAIN
mf_pagecache_single_1k_t_SOURCES = $(mf_pagecache_single_src)
mf_pagecache_single_8k_t_SOURCES = $(mf_pagecache_single_src)
mf_pagecache_single_64k_t_SOURCES = $(mf_pagecache_single_src)
mf_pagecache_single_1k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024
mf_pagecache_single_8k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=8192
mf_pagecache_single_64k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536
mf_pagecache_consist_1k_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024
mf_pagecache_consist_64k_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536
mf_pagecache_consist_1kHC_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kHC_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY
mf_pagecache_consist_64kHC_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64kHC_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY
mf_pagecache_consist_1kRD_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kRD_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_READERS
mf_pagecache_consist_64kRD_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64kRD_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_READERS
mf_pagecache_consist_1kWR_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kWR_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_WRITERS
mf_pagecache_consist_64kWR_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64kWR_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_WRITERS
CLEANFILES = my_pagecache_debug.log page_cache_test_file_1
#include "mysys_priv.h"
#include "../include/my_pthread.h"
#include "../include/pagecache.h"
#include <string.h>
#include "my_dir.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include "../unittest/mytap/tap.h"
#include <my_pthread.h>
/*#define PAGE_SIZE 65536*/
/*
TODO: use pthread_join instead of wait_for_thread_count_to_be_zero, like in
my_atomic-t.c (see BUG#22320).
Use diag() instead of fprintf(stderr). Use ok() and plan().
*/
#include <tap.h>
#include <my_sys.h>
#include <m_string.h>
#include "test_file.h"
#define PCACHE_SIZE (PAGE_SIZE*1024*8)
#ifndef DBUG_OFF
......@@ -443,5 +441,5 @@ int main(int argc, char **argv __attribute__((unused)))
DBUG_PRINT("info", ("Program end"));
DBUG_RETURN(0);
DBUG_RETURN(exit_status());
}
#include "mysys_priv.h"
#include "../include/my_pthread.h"
#include "../include/pagecache.h"
#include "my_dir.h"
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include "../unittest/mytap/tap.h"
/*
TODO: use pthread_join instead of wait_for_thread_count_to_be_zero, like in
my_atomic-t.c (see BUG#22320).
Use diag() instead of fprintf(stderr).
*/
#include <tap.h>
#include <my_sys.h>
#include <m_string.h>
#include "test_file.h"
/* #define PAGE_SIZE 1024 */
#define PCACHE_SIZE (PAGE_SIZE*1024*10)
#ifndef DBUG_OFF
......@@ -100,7 +97,7 @@ int simple_read_write_test()
unsigned char *buffr= malloc(PAGE_SIZE);
int res;
DBUG_ENTER("simple_read_write_test");
memset(buffw, '\1', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\1');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......@@ -136,7 +133,7 @@ int simple_read_change_write_read_test()
int res;
DBUG_ENTER("simple_read_change_write_read_test");
/* prepare the file */
memset(buffw, '\1', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\1');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......@@ -149,7 +146,7 @@ int simple_read_change_write_read_test()
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_WRITE,
0);
memset(buffw, '\65', PAGE_SIZE/2);
bfill(buffw, PAGE_SIZE/2, '\65');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_WRITE_UNLOCK,
......@@ -190,7 +187,7 @@ int simple_pin_test()
int res;
DBUG_ENTER("simple_pin_test");
/* prepare the file */
memset(buffw, '\1', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\1');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......@@ -213,7 +210,7 @@ int simple_pin_test()
PAGECACHE_PIN_LEFT_UNPINNED,
PAGECACHE_WRITE_DELAY,
0);
memset(buffw + PAGE_SIZE/2, ((unsigned char) 129), PAGE_SIZE/2);
bfill(buffw + PAGE_SIZE/2, PAGE_SIZE/2, ((unsigned char) 129));
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_WRITE_TO_READ,
......@@ -268,7 +265,7 @@ int simple_delete_forget_test()
int res;
DBUG_ENTER("simple_delete_forget_test");
/* prepare the file */
memset(buffw, '\1', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\1');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......@@ -277,7 +274,7 @@ int simple_delete_forget_test()
0);
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
/* test */
memset(buffw, '\2', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\2');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......@@ -310,7 +307,7 @@ int simple_delete_flush_test()
int res;
DBUG_ENTER("simple_delete_flush_test");
/* prepare the file */
memset(buffw, '\1', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\1');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_WRITE,
......@@ -319,7 +316,7 @@ int simple_delete_flush_test()
0);
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
/* test */
memset(buffw, '\2', PAGE_SIZE);
bfill(buffw, PAGE_SIZE, '\2');
pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw,
PAGECACHE_PLAIN_PAGE,
PAGECACHE_LOCK_LEFT_WRITELOCKED,
......@@ -356,7 +353,7 @@ int simple_big_test()
/* prepare the file twice larger then cache */
for (i= 0; i < PCACHE_SIZE/(PAGE_SIZE/2); i++)
{
memset(buffw, (unsigned char) (i & 0xff), PAGE_SIZE);
bfill(buffw, PAGE_SIZE, (unsigned char) (i & 0xff));
desc[i].length= PAGE_SIZE;
desc[i].content= (i & 0xff);
pagecache_write(&pagecache, &file1, i, 3, (char*)buffw,
......@@ -528,6 +525,7 @@ int main(int argc, char **argv __attribute__((unused)))
my_thread_global_init();
plan(12);
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
PAGE_SIZE, 0)) == 0)
......@@ -585,5 +583,5 @@ int main(int argc, char **argv __attribute__((unused)))
DBUG_PRINT("info", ("Program end"));
DBUG_RETURN(0);
DBUG_RETURN(exit_status());
}
#include "mysys_priv.h"
#include "my_dir.h"
#include <fcntl.h>
#include <sys/stat.h>
#include <pagecache.h>
#include <tap.h>
#include <my_sys.h>
#include <my_dir.h>
#include "test_file.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment