LTP GCOV extension - code coverage report
Current view: directory - storage/maria/unittest - ma_maria_log_cleanup.c
Test: mtr_and_unit.info
Date: 2009-03-05 Instrumented lines: 15
Code covered: 66.7 % Executed lines: 10

       1                 : /* Copyright (C) 2006-2008 MySQL AB
       2                 : 
       3                 :    This program is free software; you can redistribute it and/or modify
       4                 :    it under the terms of the GNU General Public License as published by
       5                 :    the Free Software Foundation; version 2 of the License.
       6                 : 
       7                 :    This program is distributed in the hope that it will be useful,
       8                 :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9                 :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10                 :    GNU General Public License for more details.
      11                 : 
      12                 :    You should have received a copy of the GNU General Public License
      13                 :    along with this program; if not, write to the Free Software
      14                 :    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
      15                 : 
      16                 : #include "../maria_def.h"
      17                 : #include <my_dir.h>
      18                 : 
      19                 : my_bool maria_log_remove()
      20              19 : {
      21                 :   MY_DIR *dirp;
      22                 :   uint i;
      23                 :   MY_STAT stat_buff;
      24                 :   char file_name[FN_REFLEN];
      25                 : 
      26                 :   /* Removes control file */
      27              19 :   if (fn_format(file_name, CONTROL_FILE_BASE_NAME,
      28                 :                 maria_data_root, "", MYF(MY_WME)) == NullS)
      29               0 :     return 1;
      30              19 :   if (my_stat(file_name, &stat_buff, MYF(0)) &&
      31                 :       my_delete(file_name, MYF(MY_WME)) != 0)
      32               0 :     return 1;
      33                 : 
      34                 :   /* Finds and removes transaction log files */
      35              19 :   if (!(dirp = my_dir(maria_data_root, MYF(MY_DONT_SORT))))
      36               0 :     return 1;
      37                 : 
      38            7060 :   for (i= 0; i < dirp->number_off_files; i++)
      39                 :   {
      40            7041 :     char *file= dirp->dir_entry[i].name;
      41            7041 :     if (strncmp(file, "maria_log.", 10) == 0 &&
      42                 :         file[10] >= '0' && file[10] <= '9' &&
      43                 :         file[11] >= '0' && file[11] <= '9' &&
      44                 :         file[12] >= '0' && file[12] <= '9' &&
      45                 :         file[13] >= '0' && file[13] <= '9' &&
      46                 :         file[14] >= '0' && file[14] <= '9' &&
      47                 :         file[15] >= '0' && file[15] <= '9' &&
      48                 :         file[16] >= '0' && file[16] <= '9' &&
      49                 :         file[17] >= '0' && file[17] <= '9' &&
      50                 :         file[18] == '\0')
      51                 :     {
      52              30 :       if (fn_format(file_name, file,
      53                 :                     maria_data_root, "", MYF(MY_WME)) == NullS ||
      54                 :           my_delete(file_name, MYF(MY_WME)) != 0)
      55                 :       {
      56               0 :         my_dirend(dirp);
      57               0 :         return 1;
      58                 :       }
      59                 :     }
      60                 :   }
      61              19 :   my_dirend(dirp);
      62              19 :   return 0;
      63                 : }
      64                 : 

Generated by: LTP GCOV extension version 1.4