Changes: add coverage enablers to the code

RevBy: Pertti Kellomäki

Details: explicitly flush the coverage data to disk in a few key locations
pull/1/head
Oskari Timperi 15 years ago
parent 5087fbdfc0
commit 56fc682152

@ -86,9 +86,9 @@ add_definitions(-DDEBUG_LOGGING_DISABLED)
# Build with test coverage switch if BUILD_COVERAGE environment variable is set
if ($ENV{BUILD_COVERAGE})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -ftest-coverage -fprofile-arcs")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -DWITH_COVERAGE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -DWITH_COVERAGE")
set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} --coverage")
endif ($ENV{BUILD_COVERAGE})
# Sub build: applauncherd

@ -0,0 +1,43 @@
/***************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of applauncherd
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef COVERAGE_H
#define COVERAGE_H
#ifdef WITH_COVERAGE
#ifdef __cplusplus
extern "C" void __gcov_flush(void);
extern "C" pid_t __gcov_fork(void);
extern "C" int __gcov_execv(const char *path, char *const argv[]);
extern "C" int __gcov_execve(const char *path, char *const argv[],
char *const envp[]);
#endif // __cplusplus
#define _exit(status) { \
__gcov_flush(); \
_exit(status); \
}
#define fork() __gcov_fork()
#define execv(path, argv) __gcov_execv((path), (argv))
#define execve(path, argv, envp) __gcov_execve((path), (argv), (envp))
#endif // WITH_COVERAGE
#endif // COVERAGE_H

@ -6,6 +6,7 @@
#include <QtConcurrentRun>
#include <QApplication>
#include <MApplication>
#include "coverage.h"
int EventHandler::m_sighupFd[2];
struct sigaction EventHandler::m_oldSigAction;
@ -89,9 +90,13 @@ void EventHandler::accept()
void EventHandler::notifyThemeChange()
{
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
// only MApplication is connected to this signal
MApplication::quit();
::_exit(EXIT_SUCCESS);
_exit(EXIT_SUCCESS);
}
//
@ -109,12 +114,16 @@ void EventHandler::hupSignalHandler(int)
void EventHandler::handleSigHup()
{
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
if (m_type == MEventHandler)
MApplication::quit();
else if (m_type == QEventHandler)
QApplication::quit();
::_exit(EXIT_SUCCESS);
_exit(EXIT_SUCCESS);
}
bool EventHandler::setupUnixSignalHandlers()

@ -26,6 +26,8 @@
#include <mcomponentcache.h>
#endif
#include "coverage.h"
const string EBooster::m_socketId = "/tmp/booste";
const string EBooster::m_temporaryProcessName = "booster-e";

@ -57,6 +57,8 @@ namespace
}
#endif // HAVE_CREDS
#include "coverage.h"
static const int FALLBACK_GID = 126;
static gid_t getGroupId(const char *name, gid_t fallback)
@ -481,6 +483,10 @@ int Booster::launchProcess()
// Load the application and find out the address of main()
void* handle = loadMain();
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
// Jump to main()
const int retVal = m_appData->entry()(m_appData->argc(), const_cast<char **>(m_appData->argv()));
m_appData->deleteArgv();

@ -38,6 +38,8 @@
#include <cstring>
#include <cstdio>
#include "coverage.h"
Daemon * Daemon::m_instance = NULL;
int Daemon::m_lockFd = -1;
const int Daemon::m_boosterSleepTime = 2;
@ -766,4 +768,8 @@ Daemon::~Daemon()
{
delete m_socketManager;
delete m_singleInstance;
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
}

@ -24,6 +24,7 @@
#include <cstdio>
#include <unistd.h>
#include "coverage.h"
bool Logger::m_isOpened = false;
bool Logger::m_debugMode = false;

@ -27,6 +27,8 @@
#include <X11/Xutil.h>
#endif
#include "coverage.h"
MDeclarativeCachePrivate * const MDeclarativeCache::d_ptr = new MDeclarativeCachePrivate;
const int MDeclarativeCachePrivate::ARGV_LIMIT = 32;
@ -45,6 +47,10 @@ MDeclarativeCachePrivate::~MDeclarativeCachePrivate()
{
delete qDeclarativeViewInstance;
delete[] initialArgv;
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
}
void MDeclarativeCachePrivate::populate()
@ -128,6 +134,11 @@ QApplication* MDeclarativeCachePrivate::qApplication(int &argc, char **argv)
}
}
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
return qApplicationInstance;
}
@ -140,6 +151,11 @@ QDeclarativeView* MDeclarativeCachePrivate::qDeclarativeView()
} else {
returnValue = new QDeclarativeView();
}
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
return returnValue;
}
@ -166,6 +182,10 @@ QString MDeclarativeCachePrivate::applicationFilePath()
void MDeclarativeCache::populate()
{
d_ptr->populate();
#ifdef WITH_COVERAGE
__gcov_flush();
#endif
}
QApplication* MDeclarativeCache::qApplication(int &argc, char **argv)

Loading…
Cancel
Save