/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
*
* Date and time self-tests
*
*/
/* Forcibly enable assertions */
#include <time.h>
/** A mktime() test */
struct mktime_test {
/** Broken-down time */
/** Day of the week */
int wday;
/** Day of the year */
int yday;
/** Seconds since the Epoch */
};
/**
* Define a mktime() test
*
* @v name Test name
* @v SEC Seconds [0,60]
* @v MIN Minutes [0,59]
* @v HOUR Hour [0,23]
* @v MDAY Day of month [1,31]
* @v MON Month of year [0,11]
* @v YEAR Years since 1900
* @v WDAY Day of week [0,6] (Sunday=0)
* @v YDAY Day of year [0,365]
* @v ISDST Daylight savings flag (ignored)
* @v TIME Seconds since the Epoch
* @ret test mktime() test
*
* This macro is designed to make it easy to generate test vectors in
* Perl using
*
* print join ", ", gmtime ( $time ), $time."ULL";
*
*/
static struct mktime_test name = { \
.tm = { \
}, \
}
/**
* Report mktime() test result
*
* @v test mktime() test
*/
} while ( 0 )
/* Start of the Epoch */
/* Birth of iPXE as a new project */
/* Random test vectors generated using Perl's gmtime() */
/**
* Perform date and time self-tests
*
*/
static void time_test_exec ( void ) {
mktime_ok ( &mktime_epoch );
mktime_ok ( &mktime_ipxe );
}
/** Date and time self-test */
.name = "time",
.exec = time_test_exec,
};