aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-10-25 11:10:25 +0200
committerJiri Vanek <[email protected]>2013-10-25 11:10:25 +0200
commit2783ad50d2746de5a8aaf302f11e24b11088eaef (patch)
tree23a35caac4205ef18ea5fb4d03929d229373000b
parent3d77704be0d579ad538e4f5e7150b58a850ac498 (diff)
All output messages redirected to PLUGIN_{DEBUG,ERROR} macros
-rw-r--r--ChangeLog15
-rw-r--r--plugin/icedteanp/IcedTeaJavaRequestProcessor.cc20
-rw-r--r--plugin/icedteanp/IcedTeaNPPlugin.cc12
-rw-r--r--plugin/icedteanp/IcedTeaPluginRequestProcessor.cc6
-rw-r--r--plugin/icedteanp/IcedTeaPluginUtils.cc6
-rw-r--r--plugin/icedteanp/IcedTeaPluginUtils.h2
-rw-r--r--plugin/icedteanp/IcedTeaScriptablePluginObject.cc40
-rw-r--r--plugin/icedteanp/IcedTeaScriptablePluginObject.h6
-rw-r--r--tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc62
9 files changed, 123 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index be3ef6b..f4b5b8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2013-10-25 Jiri Vanek <[email protected]>
+ all output messages redirected to PLUGIN_{DEBUG,ERROR} macros
+ * plugin/icedteanp/IcedTeaJavaRequestProcessor.cc: affected
+ * plugin/icedteanp/IcedTeaNPPlugin.cc: affected
+ * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc: affected
+ * plugin/icedteanp/IcedTeaPluginUtils.cc: affected
+ * plugin/icedteanp/IcedTeaPluginUtils.h: affected
+ * plugin/icedteanp/IcedTeaRunnable.cc: affected
+ * plugin/icedteanp/IcedTeaScriptablePluginObject.cc: affected
+ * tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc: added
+ (TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_on)) and
+ (TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_off)) which call new
+ (doDebugErrorRun) and are measuring refactoring impacts.
+
+2013-10-25 Jiri Vanek <[email protected]>
+
* netx/net/sourceforge/jnlp/util/logging/OutputController.java:
(getCallerClass) now gets out also from sun.applet.PluginDebug class.
diff --git a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
index 0d65bd4..778bab8 100644
--- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
+++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
@@ -78,7 +78,7 @@ JavaRequestProcessor::newMessageOnBus(const char* message)
result->error_msg->append(" ");
}
- printf("Error on Java side: %s\n", result->error_msg->c_str());
+ PLUGIN_ERROR("Error on Java side: %s\n", result->error_msg->c_str());
result->error_occurred = true;
result_ready = true;
@@ -947,7 +947,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
java_result = java_request.newArray(java_array_type, length_str);
if (java_result->error_occurred) {
- printf("Unable to create array\n");
+ PLUGIN_ERROR("Unable to create array\n");
id->append("-1");
return;
}
@@ -966,7 +966,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
createJavaObjectFromVariant(instance, value, &value_id);
if (value_id == "-1") {
- printf("Unable to populate array\n");
+ PLUGIN_ERROR("Unable to populate array\n");
id->clear();
id->append("-1");
return;
@@ -1002,7 +1002,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to get JSObject class id\n");
+ PLUGIN_ERROR("Unable to get JSObject class id\n");
id->clear();
id->append("-1");
return;
@@ -1018,7 +1018,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to get JSObject constructor id\n");
+ PLUGIN_ERROR("Unable to get JSObject constructor id\n");
id->clear();
id->append("-1");
return;
@@ -1042,7 +1042,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to create JSObject\n");
+ PLUGIN_ERROR("Unable to create JSObject\n");
id->clear();
id->append("-1");
return;
@@ -1059,7 +1059,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred) {
- printf("Unable to find classid for %s\n", className.c_str());
+ PLUGIN_ERROR("Unable to find classid for %s\n", className.c_str());
id->append("-1");
return;
}
@@ -1074,7 +1074,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred) {
- printf("Unable to find string constructor for %s\n", className.c_str());
+ PLUGIN_ERROR("Unable to find string constructor for %s\n", className.c_str());
id->append("-1");
return;
}
@@ -1086,7 +1086,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
java_result = java_request.newString(stringArg);
if (java_result->error_occurred) {
- printf("Unable to create requested object\n");
+ PLUGIN_ERROR("Unable to create requested object\n");
id->append("-1");
return;
}
@@ -1099,7 +1099,7 @@ createJavaObjectFromVariant(NPP instance, NPVariant variant, std::string* id)
java_result = java_request.newObjectWithConstructor("[System]", jsObjectClassID, jsObjectConstructorID, args);
if (java_result->error_occurred) {
- printf("Unable to create requested object\n");
+ PLUGIN_ERROR("Unable to create requested object\n");
id->append("-1");
return;
}
diff --git a/plugin/icedteanp/IcedTeaNPPlugin.cc b/plugin/icedteanp/IcedTeaNPPlugin.cc
index 789ff78..7a5428f 100644
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc
@@ -248,7 +248,7 @@ static std::string get_plugin_executable(){
if (IcedTeaPluginUtilities::file_exists(custom_jre+"/bin/java")){
return custom_jre+"/bin/java";
} else {
- fprintf(stderr, "Your custom jre (/bin/java check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
+ PLUGIN_ERROR("Your custom jre (/bin/java check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
}
}
return appletviewer_default_executable;
@@ -261,7 +261,7 @@ static std::string get_plugin_rt_jar(){
if (IcedTeaPluginUtilities::file_exists(custom_jre+"/lib/rt.jar")){
return custom_jre+"/lib/rt.jar";
} else {
- fprintf(stderr, "Your custom jre (/lib/rt.jar check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
+ PLUGIN_ERROR("Your custom jre (/lib/rt.jar check) %s is not valid. Please fix %s in your %s. In attempt to run using default one. \n", custom_jre.c_str(), custom_jre_key.c_str(), default_file_ITW_deploy_props_name.c_str());
}
}
return appletviewer_default_rtjar;
@@ -317,7 +317,7 @@ ITNP_New (NPMIMEType pluginType, NPP instance, uint16_t mode,
identifier = browser_functions.getstringidentifier("document");
if (!browser_functions.hasproperty(instance, window_ptr, identifier))
{
- printf("%s not found!\n", "document");
+ PLUGIN_ERROR("%s not found!\n", "document");
}
browser_functions.getproperty(instance, window_ptr, identifier, &member_ptr);
@@ -1903,7 +1903,7 @@ NP_Initialize (NPNetscapeFuncs* browserTable, NPPluginFuncs* pluginTable)
np_error = plugin_test_appletviewer ();
if (np_error != NPERR_NO_ERROR)
{
- fprintf(stderr, "Unable to find java executable %s\n", get_plugin_executable().c_str());
+ PLUGIN_ERROR("Unable to find java executable %s\n", get_plugin_executable().c_str());
return np_error;
}
@@ -2110,7 +2110,7 @@ get_scriptable_object(NPP instance)
if (java_result->error_occurred)
{
- printf("Error: Unable to fetch applet instance id from Java side.\n");
+ PLUGIN_ERROR("Error: Unable to fetch applet instance id from Java side.\n");
return NULL;
}
@@ -2120,7 +2120,7 @@ get_scriptable_object(NPP instance)
if (java_result->error_occurred)
{
- printf("Error: Unable to fetch applet instance id from Java side.\n");
+ PLUGIN_ERROR("Error: Unable to fetch applet instance id from Java side.\n");
return NULL;
}
diff --git a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
index a9ad33d..0e2fca6 100644
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
+++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
@@ -440,7 +440,7 @@ PluginRequestProcessor::setMember(std::vector<std::string*>* message_parts)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to get member name for setMember. Error occurred: %s\n", java_result->error_msg->c_str());
+ PLUGIN_ERROR("Unable to get member name for setMember. Error occurred: %s\n", java_result->error_msg->c_str());
//goto cleanup;
}
@@ -521,7 +521,7 @@ PluginRequestProcessor::sendMember(std::vector<std::string*>* message_parts)
// the result we want is in result_string (assuming there was no error)
if (java_result->error_occurred)
{
- printf("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());
+ PLUGIN_ERROR("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());
//goto cleanup;
}
@@ -800,7 +800,7 @@ _getMember(void* data)
if (!browser_functions.hasproperty(instance, parent_ptr, member_identifier))
{
- printf("%s not found!\n", IcedTeaPluginUtilities::NPIdentifierAsString(member_identifier).c_str());
+ PLUGIN_ERROR("%s not found!\n", IcedTeaPluginUtilities::NPIdentifierAsString(member_identifier).c_str());
}
((AsyncCallThreadData*) data)->call_successful = browser_functions.getproperty(instance, parent_ptr, member_identifier, member_ptr);
diff --git a/plugin/icedteanp/IcedTeaPluginUtils.cc b/plugin/icedteanp/IcedTeaPluginUtils.cc
index d8ae1ee..b8881ac 100644
--- a/plugin/icedteanp/IcedTeaPluginUtils.cc
+++ b/plugin/icedteanp/IcedTeaPluginUtils.cc
@@ -399,7 +399,7 @@ IcedTeaPluginUtilities::getUTF16LEString(int length, int begin, std::vector<std:
wchar_t c;
- if (plugin_debug) printf("Converted UTF-16LE string: ");
+ PLUGIN_DEBUG("Converted UTF-16LE string: ");
result_unicode_str->clear();
for (int i = begin; i < begin+length; i+=2)
@@ -413,14 +413,14 @@ IcedTeaPluginUtilities::getUTF16LEString(int length, int begin, std::vector<std:
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9'))
{
- if (plugin_debug) printf("%c", c);
+ PLUGIN_DEBUG("%c", c);
}
result_unicode_str->push_back(c);
}
// not routing via debug print macros due to wide-string issues
- if (plugin_debug) printf(". Length=%d\n", result_unicode_str->length());
+ PLUGIN_DEBUG(". Length=%d\n", result_unicode_str->length());
}
/*
diff --git a/plugin/icedteanp/IcedTeaPluginUtils.h b/plugin/icedteanp/IcedTeaPluginUtils.h
index 02b14e6..d5b1ef6 100644
--- a/plugin/icedteanp/IcedTeaPluginUtils.h
+++ b/plugin/icedteanp/IcedTeaPluginUtils.h
@@ -82,7 +82,7 @@ do \
{ \
if (((JavaResultData*) result_data)->error_occurred) \
{ \
- printf("Error: Error occurred on Java side: %s.\n", \
+ PLUGIN_ERROR("Error: Error occurred on Java side: %s.\n", \
((JavaResultData*) result_data)->error_msg->c_str()); \
return; \
} \
diff --git a/plugin/icedteanp/IcedTeaScriptablePluginObject.cc b/plugin/icedteanp/IcedTeaScriptablePluginObject.cc
index 51cbcd4..416cde6 100644
--- a/plugin/icedteanp/IcedTeaScriptablePluginObject.cc
+++ b/plugin/icedteanp/IcedTeaScriptablePluginObject.cc
@@ -49,19 +49,19 @@ IcedTeaScriptablePluginObject::IcedTeaScriptablePluginObject(NPP instance)
void
IcedTeaScriptablePluginObject::deAllocate(NPObject *npobj)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::deAllocate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::deAllocate %p\n", npobj);
}
void
IcedTeaScriptablePluginObject::invalidate(NPObject *npobj)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::invalidate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::invalidate %p\n", npobj);
}
bool
IcedTeaScriptablePluginObject::hasMethod(NPObject *npobj, NPIdentifier name_id)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::hasMethod %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::hasMethod %p\n", npobj);
return false;
}
@@ -69,7 +69,7 @@ bool
IcedTeaScriptablePluginObject::invoke(NPObject *npobj, NPIdentifier name_id, const NPVariant *args,
uint32_t argCount,NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::invoke %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::invoke %p\n", npobj);
return false;
}
@@ -77,14 +77,14 @@ bool
IcedTeaScriptablePluginObject::invokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::invokeDefault %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::invokeDefault %p\n", npobj);
return false;
}
bool
IcedTeaScriptablePluginObject::hasProperty(NPObject *npobj, NPIdentifier name_id)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::hasProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::hasProperty %p\n", npobj);
return false;
}
@@ -97,7 +97,7 @@ IcedTeaScriptablePluginObject::getProperty(NPObject *npobj, NPIdentifier name_id
//NPObject* obj = IcedTeaScriptableJavaPackageObject::get_scriptable_java_package_object(getInstanceFromMemberPtr(npobj), name);
//OBJECT_TO_NPVARIANT(obj, *result);
- //printf ("Filling variant %p with object %p\n", result);
+ //PLUGIN_ERROR ("Filling variant %p with object %p\n", result);
}
return false;
@@ -106,21 +106,21 @@ IcedTeaScriptablePluginObject::getProperty(NPObject *npobj, NPIdentifier name_id
bool
IcedTeaScriptablePluginObject::setProperty(NPObject *npobj, NPIdentifier name_id, const NPVariant *value)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::setProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::setProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptablePluginObject::removeProperty(NPObject *npobj, NPIdentifier name_id)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::removeProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::removeProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptablePluginObject::enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::enumerate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::enumerate %p\n", npobj);
return false;
}
@@ -128,7 +128,7 @@ bool
IcedTeaScriptablePluginObject::construct(NPObject *npobj, const NPVariant *args, uint32_t argCount,
NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptablePluginObject::construct %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptablePluginObject::construct %p\n", npobj);
return false;
}
@@ -221,7 +221,7 @@ bool
IcedTeaScriptableJavaPackageObject::invoke(NPObject *npobj, NPIdentifier name_id, const NPVariant *args,
uint32_t argCount,NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invoke %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invoke %p\n", npobj);
return false;
}
@@ -229,7 +229,7 @@ bool
IcedTeaScriptableJavaPackageObject::invokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invokeDefault %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invokeDefault %p\n", npobj);
return false;
}
@@ -338,14 +338,14 @@ IcedTeaScriptableJavaPackageObject::setProperty(NPObject *npobj, NPIdentifier na
bool
IcedTeaScriptableJavaPackageObject::removeProperty(NPObject *npobj, NPIdentifier name_id)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::removeProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::removeProperty %p\n", npobj);
return false;
}
bool
IcedTeaScriptableJavaPackageObject::enumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::enumerate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::enumerate %p\n", npobj);
return false;
}
@@ -353,7 +353,7 @@ bool
IcedTeaScriptableJavaPackageObject::construct(NPObject *npobj, const NPVariant *args, uint32_t argCount,
NPVariant *result)
{
- printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::construct %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaPackageObject::construct %p\n", npobj);
return false;
}
@@ -524,7 +524,7 @@ IcedTeaScriptableJavaObject::invoke(NPObject *npobj, NPIdentifier name_id, const
if (id == "-1")
{
- printf("Unable to create arguments on Java side\n");
+ PLUGIN_ERROR("Unable to create arguments on Java side\n");
return false;
}
@@ -622,7 +622,7 @@ IcedTeaScriptableJavaObject::getProperty(NPObject *npobj, NPIdentifier name_id,
java_result = java_request.getArrayLength(instance_id);
if (java_result->error_occurred)
{
- printf("ERROR: Couldn't fetch array length\n");
+ PLUGIN_ERROR("ERROR: Couldn't fetch array length\n");
return false;
}
@@ -698,7 +698,7 @@ IcedTeaScriptableJavaObject::setProperty(NPObject *npobj, NPIdentifier name_id,
// If array
if (scriptable_object->is_object_array && name == "length")
{
- printf("ERROR: Array length is not a modifiable property\n");
+ PLUGIN_ERROR("ERROR: Array length is not a modifiable property\n");
return false;
} else if ( scriptable_object->is_object_array &&
browser_functions.intfromidentifier(name_id) >= 0) // else if array and requesting index
@@ -707,7 +707,7 @@ IcedTeaScriptableJavaObject::setProperty(NPObject *npobj, NPIdentifier name_id,
JavaResultData* java_result = java_request.getArrayLength(instance_id);
if (java_result->error_occurred)
{
- printf("ERROR: Couldn't fetch array length\n");
+ PLUGIN_ERROR("ERROR: Couldn't fetch array length\n");
return false;
}
diff --git a/plugin/icedteanp/IcedTeaScriptablePluginObject.h b/plugin/icedteanp/IcedTeaScriptablePluginObject.h
index a02df53..ebfe34c 100644
--- a/plugin/icedteanp/IcedTeaScriptablePluginObject.h
+++ b/plugin/icedteanp/IcedTeaScriptablePluginObject.h
@@ -175,7 +175,7 @@ public:
const NPVariant *args, uint32_t argCount, NPVariant *result);
static bool invokeDefault(NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result) {
- printf ("** Unimplemented: IcedTeaScriptableJavaObject::invokeDefault %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaObject::invokeDefault %p\n", npobj);
return false;
}
static bool hasProperty(NPObject *npobj, NPIdentifier name_id);
@@ -185,12 +185,12 @@ public:
const NPVariant *value);
static bool removeProperty(NPObject *npobj, NPIdentifier name_id) {
- printf ("** Unimplemented: IcedTeaScriptableJavaObject::removeProperty %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaObject::removeProperty %p\n", npobj);
return false;
}
static bool enumerate(NPObject *npobj, NPIdentifier **value,
uint32_t *count) {
- printf ("** Unimplemented: IcedTeaScriptableJavaObject::enumerate %p\n", npobj);
+ PLUGIN_ERROR ("** Unimplemented: IcedTeaScriptableJavaObject::enumerate %p\n", npobj);
return false;
}
static bool construct(NPObject *npobj, const NPVariant *args,
diff --git a/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc b/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc
index ac0e0d3..e17caa5 100644
--- a/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc
+++ b/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc
@@ -36,15 +36,20 @@
#include <fstream>
#include <UnitTest++.h>
+#include <stdio.h>
#include <npapi.h>
+
#include "browser_mock.h"
#include "MemoryLeakDetector.h"
#include "IcedTeaPluginUtils.h"
#include "IcedTeaNPPlugin.h"
+
+void doDebugErrorRun();
+
TEST(NPVariantAsString) {
NPVariant var;
STRINGZ_TO_NPVARIANT("test", var);
@@ -131,3 +136,60 @@ TEST(file_exists) {
bool b = IcedTeaPluginUtilities::file_exists(f1);
CHECK_EQUAL(b, false);
}
+
+
+void doDebugErrorRun() {
+ FILE* old1 = stdout;
+ FILE* old2 = stderr;
+ char* buf1 = " ";
+ char* buf2 = " ";
+ stdout = fmemopen (buf1, strlen (buf1), "rw");
+ stderr = fmemopen (buf2, strlen (buf2), "rw");
+
+ clock_t begin1, end1;
+ clock_t begin2, end2;
+ int i;
+ int max = 1000000;
+ std::string hello = std::string("hello");
+ std::string eello = std::string("eello");
+
+ begin1 = clock();
+ for (i = 0 ; i < max ; i++ ) {
+ PLUGIN_DEBUG("hello \n");
+ PLUGIN_DEBUG("hello %s\n", hello.c_str());
+ PLUGIN_DEBUG("hello %d %d\n", 10 , 0.5);
+ PLUGIN_DEBUG("hello %s %s \n", hello.c_str() , hello.c_str());
+ PLUGIN_DEBUG("hello %s %d %s %d\n", hello.c_str() ,10, hello.c_str(), 0.5);
+ }
+ end1 = clock();
+ begin2 = clock();
+ for (i = 0 ; i < max ; i++ ) {
+ PLUGIN_ERROR("eello \n");
+ PLUGIN_ERROR("eello %s\n", eello.c_str());
+ PLUGIN_ERROR("eello %d %d\n", 10 , 0.5);
+ PLUGIN_ERROR("eello %s %s \n", eello.c_str() , eello.c_str());
+ PLUGIN_ERROR("eello %s %d %s %d\n", eello.c_str() ,10, eello.c_str(), 0.5);
+ }
+ end2 = clock();
+ fclose(stdout);
+ fclose(stderr);
+ stdout = old1;
+ stderr = old2;
+ long time_spent1 = ((end1 - begin1));
+ long time_spent2 = ((end2 - begin2));
+ fprintf (stdout, " PLUGIN_DEBUG %d, ", time_spent1);
+ fprintf (stdout, "PLUGIN_ERROR %d\n", time_spent2);
+}
+
+TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_on) {
+ bool plugin_debug_backup = plugin_debug;
+ plugin_debug = true;
+ doDebugErrorRun();
+ plugin_debug = plugin_debug_backup;
+}
+TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_off) {
+ bool plugin_debug_backup = plugin_debug;
+ plugin_debug = false;
+ doDebugErrorRun();
+ plugin_debug = plugin_debug_backup;
+}