aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xemulator/opengl/host/tools/emugen/tests/run-tests.sh129
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp82
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h12
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h17
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h23
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h17
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp62
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h28
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp39
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h12
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h21
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp38
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h17
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib12
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in3
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types9
22 files changed, 629 insertions, 0 deletions
diff --git a/emulator/opengl/host/tools/emugen/tests/run-tests.sh b/emulator/opengl/host/tools/emugen/tests/run-tests.sh
new file mode 100755
index 0000000..67409ed
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/run-tests.sh
@@ -0,0 +1,129 @@
+#!/bin/sh
+
+# Copyright 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+set -e
+
+export LANG=C
+export LC_ALL=C
+
+PROGDIR=$(dirname "$0")
+PROGNAME=$(basename "$0")
+
+fatal () {
+ echo "ERROR: $@"
+ exit 1
+}
+
+OPT_EMUGEN=
+OPT_HELP=
+OPT_OUT_DIR=
+OPT_TOOL=
+
+for OPT; do
+ OPTARG=$(expr "x$OPT" : "x[^=]*=\\(.*\\)" || true)
+ case $OPT in
+ --help|-h|-?)
+ OPT_HELP=true
+ ;;
+ --emugen=*)
+ OPT_EMUGEN=$OPTARG
+ ;;
+ --out-dir=*)
+ OPT_OUT_DIR=$OPTARG
+ ;;
+ --tool=*)
+ OPT_TOOL=$OPTARG
+ ;;
+ -*)
+ fatal "Invalid option '$OPT', see --help."
+ ;;
+ *)
+ fatal "This script doesn't take arguments, see --help."
+ ;;
+ esac
+done
+
+if [ "$OPT_HELP" ]; then
+ cat <<EOF
+Usage: $PROGNAME [options]
+
+Run the emugen test suite. This scripts looks for sub-directories
+named t.<number>/input, and uses them as input to 'emugen'. It then
+compares the output to t.<number>/expected/ content.
+
+Valid options:
+ --help|-h|-? Print this help.
+ --out-dir=<dir> Generate outputs into <dir>.
+ --emugen=<program> Emugen program path, if not in path.
+ --tool=<tool> Launch visual diff tool in case of differences.
+EOF
+ exit 0
+fi
+
+# Find emugen program
+EMUGEN=
+if [ "$OPT_EMUGEN" ]; then
+ EMUGEN=$OPT_EMUGEN
+else
+ EMUGEN=$(which emugen 2>/dev/null || true)
+ if [ -z "$EMUGEN" ]; then
+ fatal "Cannot find 'emugen' program in PATH, use --emugen=<program> option."
+ fi
+ echo "Auto-config: --emugen=$EMUGEN"
+fi
+if [ ! -f "$EMUGEN" ]; then
+ fatal "Emugen program doesn't exist: $EMUGEN"
+fi
+
+# Create output directory.
+OUT_DIR=
+if [ "$OPT_OUT_DIR" ]; then
+ OUT_DIR=$OPT_OUT_DIR
+else
+ OUT_DIR=/tmp/$USER-emugen-testing
+ echo "Auto-config: --out-dir=$OUT_DIR"
+fi
+mkdir -p "$OUT_DIR" && rm -rf "$OUT_DIR/emugen"
+
+OUT_DIR=$OUT_DIR/emugen
+
+# Find test directories
+TEST_DIRS=$(cd "$PROGDIR" && find . -name "t.*" | sed -e 's|^\./||')
+for TEST_DIR in $TEST_DIRS; do
+ IN=$PROGDIR/$TEST_DIR/input
+ PREFIXES=$(cd $IN && find . -name "*.in" | sed -e 's|^\./||g' -e 's|\.in$||g')
+ OUT=$OUT_DIR/$TEST_DIR
+ mkdir -p "$OUT/encoder"
+ mkdir -p "$OUT/decoder"
+ mkdir -p "$OUT/wrapper"
+ for PREFIX in $PREFIXES; do
+ echo "Processing $IN/foo.*"
+ $EMUGEN -i "$PROGDIR/$TEST_DIR/input" -D "$OUT/decoder" -E "$OUT/encoder" -W "$OUT/wrapper" $PREFIX
+ done
+ if ! diff -qr "$PROGDIR/$TEST_DIR/expected" "$OUT"; then
+ if [ "$OPT_TOOL" ]; then
+ $OPT_TOOL "$PROGDIR/$TEST_DIR/expected" "$OUT"
+ else
+ echo "ERROR: Invalid differences between actual and expected output!"
+ diff -burN "$PROGDIR/$TEST_DIR/expected" "$OUT"
+ exit 1
+ fi
+ fi
+done
+
+echo "All good!"
+exit 0
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
new file mode 100644
index 0000000..1f904cf
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
@@ -0,0 +1,82 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_opcodes.h"
+
+#include "foo_dec.h"
+
+
+#include "ProtocolUtils.h"
+
+#include <stdio.h>
+
+typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
+
+#ifdef DEBUG_PRINTOUT
+# define DEBUG(...) fprintf(stderr, __VA_ARGS__)
+#else
+# define DEBUG(...) ((void)0)
+#endif
+
+#ifdef CHECK_GLERROR
+# define SET_LASTCALL(name) sprintf(lastCall, #name)
+#else
+# define SET_LASTCALL(name) ((void)0)
+#endif
+
+using namespace emugl;
+
+size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream)
+{
+
+ size_t pos = 0;
+ if (len < 8) return pos;
+ unsigned char *ptr = (unsigned char *)buf;
+ bool unknownOpcode = false;
+#ifdef CHECK_GL_ERROR
+ char lastCall[256] = {0};
+#endif
+ while ((len - pos >= 8) && !unknownOpcode) {
+ uint32_t opcode = *(uint32_t *)ptr;
+ size_t packetLen = *(uint32_t *)(ptr + 4);
+ if (len - pos < packetLen) return pos;
+ switch(opcode) {
+ case OP_fooAlphaFunc: {
+ FooInt var_func = Unpack<FooInt,uint32_t>(ptr + 8);
+ FooFloat var_ref = Unpack<FooFloat,uint32_t>(ptr + 8 + 4);
+ DEBUG("foo(%p): fooAlphaFunc(%d %f )\n", stream,var_func, var_ref);
+ this->fooAlphaFunc(var_func, var_ref);
+ SET_LASTCALL("fooAlphaFunc");
+ break;
+ }
+ case OP_fooIsBuffer: {
+ uint32_t size_stuff __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
+ InputBuffer inptr_stuff(ptr + 8 + 4, size_stuff);
+ size_t totalTmpSize = sizeof(FooBoolean);
+ unsigned char *tmpBuf = stream->alloc(totalTmpSize);
+ DEBUG("foo(%p): fooIsBuffer(%p(%u) )\n", stream,(void*)(inptr_stuff.get()), size_stuff);
+ *(FooBoolean *)(&tmpBuf[0]) = this->fooIsBuffer((void*)(inptr_stuff.get()));
+ stream->flush();
+ SET_LASTCALL("fooIsBuffer");
+ break;
+ }
+ case OP_fooUnsupported: {
+ uint32_t size_params __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
+ InputBuffer inptr_params(ptr + 8 + 4, size_params);
+ DEBUG("foo(%p): fooUnsupported(%p(%u) )\n", stream,(void*)(inptr_params.get()), size_params);
+ this->fooUnsupported((void*)(inptr_params.get()));
+ SET_LASTCALL("fooUnsupported");
+ break;
+ }
+ default:
+ unknownOpcode = true;
+ } //switch
+ if (!unknownOpcode) {
+ pos += packetLen;
+ ptr += packetLen;
+ }
+ } // while
+ return pos;
+}
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h
new file mode 100644
index 0000000..8127237
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_foo_decoder_context_t
+#define GUARD_foo_decoder_context_t
+
+#include "IOStream.h"
+#include "foo_server_context.h"
+
+
+
+struct foo_decoder_context_t : public foo_server_context_t {
+
+ size_t decode(void *buf, size_t bufsize, IOStream *stream);
+
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
new file mode 100644
index 0000000..8a73ca7
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
@@ -0,0 +1,12 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_foo_opcodes_h_
+#define __GUARD_foo_opcodes_h_
+
+#define OP_fooAlphaFunc 200
+#define OP_fooIsBuffer 201
+#define OP_fooUnsupported 202
+#define OP_last 203
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
new file mode 100644
index 0000000..7258565
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_server_context.h"
+
+
+#include <stdio.h>
+
+int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+ fooAlphaFunc = (fooAlphaFunc_server_proc_t) getProc("fooAlphaFunc", userData);
+ fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData);
+ fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData);
+ return 0;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
new file mode 100644
index 0000000..666143a
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_server_context_t_h
+#define __foo_server_context_t_h
+
+#include "foo_server_proc.h"
+
+
+struct foo_server_context_t {
+
+ fooAlphaFunc_server_proc_t fooAlphaFunc;
+ fooIsBuffer_server_proc_t fooIsBuffer;
+ fooUnsupported_server_proc_t fooUnsupported;
+ virtual ~foo_server_context_t() {}
+ int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
new file mode 100644
index 0000000..2444068
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
@@ -0,0 +1,17 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_server_proc_t_h
+#define __foo_server_proc_t_h
+
+
+
+#include "foo_types.h"
+#ifndef foo_APIENTRY
+#define foo_APIENTRY
+#endif
+typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat);
+typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*);
+typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
new file mode 100644
index 0000000..1bc2e1e
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_client_context.h"
+
+
+#include <stdio.h>
+
+int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+ fooAlphaFunc = (fooAlphaFunc_client_proc_t) getProc("fooAlphaFunc", userData);
+ fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData);
+ fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData);
+ return 0;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
new file mode 100644
index 0000000..c4e44ad
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
@@ -0,0 +1,23 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_client_context_t_h
+#define __foo_client_context_t_h
+
+#include "foo_client_proc.h"
+
+
+struct foo_client_context_t {
+
+ fooAlphaFunc_client_proc_t fooAlphaFunc;
+ fooIsBuffer_client_proc_t fooIsBuffer;
+ fooUnsupported_client_proc_t fooUnsupported;
+ virtual ~foo_client_context_t() {}
+
+ typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
+ static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+ int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+ virtual void setError(unsigned int error){};
+ virtual unsigned int getError(){ return 0; };
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
new file mode 100644
index 0000000..6b8f211
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
@@ -0,0 +1,17 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_client_proc_t_h
+#define __foo_client_proc_t_h
+
+
+
+#include "foo_types.h"
+#ifndef foo_APIENTRY
+#define foo_APIENTRY
+#endif
+typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, FooFloat);
+typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*);
+typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
new file mode 100644
index 0000000..b1f66b7
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
@@ -0,0 +1,62 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_opcodes.h"
+
+#include "foo_enc.h"
+
+
+#include <stdio.h>
+static void enc_unsupported()
+{
+ ALOGE("Function is unsupported\n");
+}
+
+void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref)
+{
+
+ foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ unsigned char *ptr;
+ const size_t packetSize = 8 + 4 + 4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_fooAlphaFunc;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ memcpy(ptr, &func, 4); ptr += 4;
+ memcpy(ptr, &ref, 4); ptr += 4;
+}
+
+FooBoolean fooIsBuffer_enc(void *self , void* stuff)
+{
+
+ foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ const unsigned int __size_stuff = (4 * sizeof(float));
+ unsigned char *ptr;
+ const size_t packetSize = 8 + __size_stuff + 1*4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_fooIsBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ *(unsigned int *)(ptr) = __size_stuff; ptr += 4;
+ memcpy(ptr, stuff, __size_stuff);ptr += __size_stuff;
+
+ FooBoolean retval;
+ stream->readback(&retval, 1);
+ return retval;
+}
+
+foo_encoder_context_t::foo_encoder_context_t(IOStream *stream)
+{
+ m_stream = stream;
+
+ fooAlphaFunc = (fooAlphaFunc_enc);
+ fooIsBuffer = (fooIsBuffer_enc);
+ fooUnsupported = (fooUnsupported_client_proc_t)(enc_unsupported);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h
new file mode 100644
index 0000000..a86956f
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.h
@@ -0,0 +1,28 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+#ifndef GUARD_foo_encoder_context_t
+#define GUARD_foo_encoder_context_t
+
+#include "IOStream.h"
+#include "foo_client_context.h"
+
+
+#include "fooUtils.h"
+#include "fooBase.h"
+
+struct foo_encoder_context_t : public foo_client_context_t {
+
+ IOStream *m_stream;
+
+ foo_encoder_context_t(IOStream *stream);
+
+
+};
+
+extern "C" {
+ void fooAlphaFunc_enc(void *self , FooInt func, FooFloat ref);
+ FooBoolean fooIsBuffer_enc(void *self , void* stuff);
+ void fooUnsupported_enc(void *self , void* params);
+};
+#endif \ No newline at end of file
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
new file mode 100644
index 0000000..1caacd2
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
@@ -0,0 +1,39 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "foo_client_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+ void fooAlphaFunc(FooInt func, FooFloat ref);
+ FooBoolean fooIsBuffer(void* stuff);
+ void fooUnsupported(void* params);
+};
+
+#endif
+#ifndef GET_CONTEXT
+static foo_client_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void foo_client_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT foo_client_context_t * ctx = getCurrentContext()
+#endif
+
+void fooAlphaFunc(FooInt func, FooFloat ref)
+{
+ GET_CONTEXT;
+ ctx->fooAlphaFunc(ctx, func, ref);
+}
+
+FooBoolean fooIsBuffer(void* stuff)
+{
+ GET_CONTEXT;
+ if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; }
+ return ctx->fooIsBuffer(ctx, stuff);
+}
+
+void fooUnsupported(void* params)
+{
+ GET_CONTEXT;
+ ctx->fooUnsupported(ctx, params);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
new file mode 100644
index 0000000..87fb3f6
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_client_ftable_t_h
+#define __foo_client_ftable_t_h
+
+
+static struct _foo_funcs_by_name {
+ const char *name;
+ void *proc;
+} foo_funcs_by_name[] = {
+ {"fooAlphaFunc", (void*)fooAlphaFunc},
+ {"fooIsBuffer", (void*)fooIsBuffer},
+ {"fooUnsupported", (void*)fooUnsupported},
+};
+static int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
new file mode 100644
index 0000000..8a73ca7
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
@@ -0,0 +1,12 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __GUARD_foo_opcodes_h_
+#define __GUARD_foo_opcodes_h_
+
+#define OP_fooAlphaFunc 200
+#define OP_fooIsBuffer 201
+#define OP_fooUnsupported 202
+#define OP_last 203
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
new file mode 100644
index 0000000..7e2d3f0
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
@@ -0,0 +1,18 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+
+
+#include <string.h>
+#include "foo_wrapper_context.h"
+
+
+#include <stdio.h>
+
+int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)
+{
+ fooAlphaFunc = (fooAlphaFunc_wrapper_proc_t) getProc("fooAlphaFunc", userData);
+ fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData);
+ fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData);
+ return 0;
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
new file mode 100644
index 0000000..047b686
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
@@ -0,0 +1,21 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_wrapper_context_t_h
+#define __foo_wrapper_context_t_h
+
+#include "foo_wrapper_proc.h"
+
+
+struct foo_wrapper_context_t {
+
+ fooAlphaFunc_wrapper_proc_t fooAlphaFunc;
+ fooIsBuffer_wrapper_proc_t fooIsBuffer;
+ fooUnsupported_wrapper_proc_t fooUnsupported;
+ virtual ~foo_wrapper_context_t() {}
+
+ typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void);
+ static void setContextAccessor(CONTEXT_ACCESSOR_TYPE *f);
+ int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
+};
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
new file mode 100644
index 0000000..2dc18a9
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
@@ -0,0 +1,38 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#include <stdio.h>
+#include <stdlib.h>
+#include "foo_wrapper_context.h"
+
+#ifndef GL_TRUE
+extern "C" {
+ void fooAlphaFunc(FooInt func, FooFloat ref);
+ FooBoolean fooIsBuffer(void* stuff);
+ void fooUnsupported(void* params);
+};
+
+#endif
+#ifndef GET_CONTEXT
+static foo_wrapper_context_t::CONTEXT_ACCESSOR_TYPE *getCurrentContext = NULL;
+void foo_wrapper_context_t::setContextAccessor(CONTEXT_ACCESSOR_TYPE *f) { getCurrentContext = f; }
+#define GET_CONTEXT foo_wrapper_context_t * ctx = getCurrentContext()
+#endif
+
+void fooAlphaFunc(FooInt func, FooFloat ref)
+{
+ GET_CONTEXT;
+ ctx->fooAlphaFunc( func, ref);
+}
+
+FooBoolean fooIsBuffer(void* stuff)
+{
+ GET_CONTEXT;
+ return ctx->fooIsBuffer( stuff);
+}
+
+void fooUnsupported(void* params)
+{
+ GET_CONTEXT;
+ ctx->fooUnsupported( params);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
new file mode 100644
index 0000000..8c707d0
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
@@ -0,0 +1,17 @@
+// Generated Code - DO NOT EDIT !!
+// generated by 'emugen'
+#ifndef __foo_wrapper_proc_t_h
+#define __foo_wrapper_proc_t_h
+
+
+
+#include "foo_types.h"
+#ifndef foo_APIENTRY
+#define foo_APIENTRY
+#endif
+typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat);
+typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*);
+typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*);
+
+
+#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib
new file mode 100644
index 0000000..14715ed
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.attrib
@@ -0,0 +1,12 @@
+GLOBAL
+ base_opcode 200
+ encoder_headers "fooUtils.h" "fooBase.h"
+
+fooIsBuffer
+ dir stuff in
+ len stuff (4 * sizeof(float))
+ param_check stuff if (n == NULL) { LOG(ERROR) << "NULL stuff"; return; }
+
+fooUnsupported
+ dir params in
+ flag unsupported
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
new file mode 100644
index 0000000..178a6b4
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
@@ -0,0 +1,3 @@
+FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref)
+FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff)
+FOO_ENTRY(void, fooUnsupported, void* params)
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
new file mode 100644
index 0000000..c4140d1
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
@@ -0,0 +1,9 @@
+FooBoolean 8 %d
+FooInt 32 %d
+FooShort 16 %d
+FooFloat 32 %f
+FooEnum 32 %08x
+FooVoid 0 %x
+FooChar 8 %d
+FooChar* 32 0x%08x
+void* 32 0x%08x \ No newline at end of file