This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*********************************************** | |
Example of the error asan gives when you run an app linked against it and use LD_PRELOAD | |
*********************************************** | |
LD_PRELOAD=./test/libmock_syscalls.so ./src/myapp | |
==34946==ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD. | |
*********************************************** | |
Example of how you can make asan happy | |
*********************************************** | |
LD_PRELOAD=libasan.so.5:./test/libmock_syscalls.so ./src/myapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# webhook.py | |
# | |
# Copyright (C) 2016 Intel Corporation | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License version 2 as | |
# published by the Free Software Foundation. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
ch = logging.StreamHandler() | |
formatter = logging.Formatter('%(levelname)s:%(message)s') | |
ch.setFormatter(formatter) | |
logger = logging.getLogger(__name__) | |
logger.addHandler(ch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _safe_append(filename, workspacedir, data): | |
"""Safely add data to a file to prevent corruption in the case of """ | |
"""power failure. """ | |
fd, tmp = tempfile.mkstemp(prefix='tmpfile', dir=workspacedir) | |
try: | |
# close it and open it again so that "with" can be used | |
os.close(fd) | |
shutil.copyfile(filename, tmp) | |
with open(tmp, 'a') as f: | |
f.write(data) |