print: Print the Ocarina version to a file

The basic/print.cpp test will write version information to a file using
both dprint() and print().

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2013-07-05 21:40:10 -04:00 committed by Anna Schumaker
parent 7c67d062df
commit b5d3a663e0
7 changed files with 54 additions and 3 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
*.swp
*.swo
*.pyc
*.run
*.test
*.tar.gz
ocarina.bin

32
include/print.h Normal file
View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2013 Bryan Schumaker.
*/
#ifndef OCARINA_PRINT_H
#define OCARINA_PRINT_H
#include <cstdio>
#include <cstdarg>
inline void print(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
#ifdef CONFIG_DEBUG
inline void dprint(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
#else /* CONFIG_DEBUG */
inline void dprint(const char *fmt, ...) {}
#endif /* CONFIG_DEBUG */
#endif /* OCARINA_PRINT_H */

View File

@ -6,7 +6,7 @@
static inline const char *get_version()
{
return "CONFIG_VERSION";
return CONFIG_VERSION;
}
#endif /* OCARINA_VERSION_H */

View File

@ -1,9 +1,23 @@
#!/usr/bin/python
Import("release", "debug")
def run_test(group, name):
cmd = "tests/%s/%s.test" % (group, name)
out = "tests/%s/%s.run" % (group, name)
good = "tests/%s/%s.good" % (group, name)
test = Command(out, None,
[ "%s > %s" % (cmd, out),
"diff -u %s %s" % (out, good)
]
)
return test
def make_test(group, src, name, env):
obj = env.StaticObject(name, src)
prog = env.Program("%s.test" % name, obj)
test = run_test(group, name)
Depends(test, prog)
Alias("tests", [obj, prog])
Alias("tests/%s" % group, [obj, prog])
Alias("tests/%s/%s" % (group, name), [obj, prog])
@ -16,6 +30,5 @@ def Test(group, src):
Export("Test")
# Read SConscript files
basic = SConscript("basic/Sconscript")

View File

@ -0,0 +1,2 @@
6.0-debug
6.0-debug

View File

@ -1,10 +1,12 @@
/*
* Prints version info to the screen when compiled in debug mode
*/
#include <print.h>
#include <version.h>
int main(int argc, char **argv)
{
print("%s\n", get_version());
dprint("%s\n", get_version());
return 0;
}

1
tests/basic/print.good Normal file
View File

@ -0,0 +1 @@
6.0