I wrote NovaProva because I was sick of writing unit tests using the venerable but clunky CUnit library. CUnit looked easy when I started writing unit tests but I soon discovered it's limitations and ended up screaming in frustration. Meanwhile over 18 months the Cyrus IMAP server project has gone from 0 unit tests to 461, of which 277 are written in C with CUnit. So that's a big itch!
At LinkedIn we run lots of Java services on Linux boxes. Java and Linux are a perfect pair. Except when they're not; then there's fireworks. This talk describes 5 situations we encountered where Java interacted with normal Linux behavior to create stunningly sub-optimal application behavior like minutes-long GC pauses. We'll deep dive to show What Java Got Wrong, why Linux behaves the way it does, and how the two can conspire to ruin your day. Finally we'll examine actual code samples showing how we fixed or hid the problems.
This document introduces Docker containers and provides examples of using Docker for networking containers across virtual machines. It discusses setting up a GRE tunnel between two VMs to connect their Docker interfaces and allow containers running on different VMs to communicate. Specific commands are provided to configure the Docker and overlay networks on each VM, establish the GRE tunnel, and run a sample container to test the connectivity.
This document discusses memory models, non-blocking primitives, and lock-free algorithms for concurrent programming. It provides code examples for implementing atomic operations like set, compareAndSet, and lazySet using the Unsafe class. It evaluates the performance of different producer-consumer algorithms like spin-wait, co-operative yielding, and buffering. The document suggests buffering generally performs best by avoiding busy-waiting and allowing other threads to run. It provides references for further information on lock-free programming.
Performance Analysis Tools for Linux Kernellcplcp1
Perf is a collection of Linux kernel tools for performance monitoring and profiling. It provides sampling and profiling of the system to analyze performance bottlenecks. Perf supports hardware events from the CPU performance counters, software events from the kernel, and tracepoint events from the kernel and loaded modules. It offers tools like perf record to sample events and store them, perf report to analyze stored samples, and perf trace to trace system events in real-time.
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)Valeriy Kravchuk
eBPF on Linux 4.9+ is probably the best way to study performance problems. Basic usage of ftrace interface, bcc tools and bpftrace, as well as main bpftrace features and commands are presented. Several typical use cases
(including adding dynamic probes to MariaDB servers, working with stack traces and creating Flame Graphs) are discussed.
[COSCUP 2021] A trip about how I contribute to LLVMDouglas Chen
Douglas Chen presented on his contributions to LLVM. He discussed his motivation with CppNameLint and Clang-Tidy projects. He covered the workflows for Phabricator code reviews, building and testing code, and provided tips for contributors. He shared moments from his experience like design changes, invalid options, and how clang-tidy and tests work. He emphasized reading documentation and discussing with reviewers when facing issues.
At LinkedIn we run lots of Java services on Linux boxes. Java and Linux are a perfect pair. Except when they're not; then there's fireworks. This talk describes 5 situations we encountered where Java interacted with normal Linux behavior to create stunningly sub-optimal application behavior like minutes-long GC pauses. We'll deep dive to show What Java Got Wrong, why Linux behaves the way it does, and how the two can conspire to ruin your day. Finally we'll examine actual code samples showing how we fixed or hid the problems.
This document introduces Docker containers and provides examples of using Docker for networking containers across virtual machines. It discusses setting up a GRE tunnel between two VMs to connect their Docker interfaces and allow containers running on different VMs to communicate. Specific commands are provided to configure the Docker and overlay networks on each VM, establish the GRE tunnel, and run a sample container to test the connectivity.
This document discusses memory models, non-blocking primitives, and lock-free algorithms for concurrent programming. It provides code examples for implementing atomic operations like set, compareAndSet, and lazySet using the Unsafe class. It evaluates the performance of different producer-consumer algorithms like spin-wait, co-operative yielding, and buffering. The document suggests buffering generally performs best by avoiding busy-waiting and allowing other threads to run. It provides references for further information on lock-free programming.
Performance Analysis Tools for Linux Kernellcplcp1
Perf is a collection of Linux kernel tools for performance monitoring and profiling. It provides sampling and profiling of the system to analyze performance bottlenecks. Perf supports hardware events from the CPU performance counters, software events from the kernel, and tracepoint events from the kernel and loaded modules. It offers tools like perf record to sample events and store them, perf report to analyze stored samples, and perf trace to trace system events in real-time.
E bpf and dynamic tracing for mariadb db as (mariadb day during fosdem 2020)Valeriy Kravchuk
eBPF on Linux 4.9+ is probably the best way to study performance problems. Basic usage of ftrace interface, bcc tools and bpftrace, as well as main bpftrace features and commands are presented. Several typical use cases
(including adding dynamic probes to MariaDB servers, working with stack traces and creating Flame Graphs) are discussed.
[COSCUP 2021] A trip about how I contribute to LLVMDouglas Chen
Douglas Chen presented on his contributions to LLVM. He discussed his motivation with CppNameLint and Clang-Tidy projects. He covered the workflows for Phabricator code reviews, building and testing code, and provided tips for contributors. He shared moments from his experience like design changes, invalid options, and how clang-tidy and tests work. He emphasized reading documentation and discussing with reviewers when facing issues.
Kselftest is a developer-friendly test framework and set of tests for the Linux kernel. It aims to help developers test the kernel more easily and frequently. Tests are contained in the kernel source code and can be built, run, installed, and packaged quickly and easily. Writing new tests and using the test code as documentation makes kselftest a good starting point for new kernel developers.
The document discusses various topics related to tuning the Java Virtual Machine (JVM) for performance, including:
1. Hotspot compiler options like method inlining that can improve performance.
2. Threading models on Solaris like M:N and 1:1 and how tuning thread-related JVM options can significantly impact throughput.
3. Memory and garbage collection tuning like selecting the right GC algorithm, tuning heap sizes, and analyzing GC logs to identify bottlenecks and optimize full GC frequency and duration.
Golang Performance : microbenchmarks, profilers, and a war storyAerospike
Slides for Brian Bulkowski's talk about Golang performance:
microbenchmarks, profilers, and a war story about optimizing the Aerospike Database Go client.
http://www.meetup.com/Go-lang-Developers-NYC/events/216650022/
The Simple Scheduler in Embedded System @ OSDC.TW 2014Jian-Hong Pan
The document describes a simple scheduler module implemented in C for embedded systems. It breaks processes into small jobs represented by functions that are scheduled in a first-in, first-out queue without preemption. This allows embedding an operating system concept into simple systems using only functions and a ready queue. Interrupts can add jobs to the queue. The scheduler and example oscilloscope application demonstrate scheduling without process state using only callbacks.
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
The document summarizes the Post Memory Corruption Memory Analysis (PMCMA) tool. PMCMA allows finding and testing exploitation scenarios resulting from invalid memory accesses. It provides a roadmap to exploitation without generating exploit code. The tool analyzes programs after crashes to overwrite memory locations in forked processes and test impact on execution flow.
[231] the simplicity of cluster apps with circuitNAVER D2
This document discusses Circuit, a lightweight cluster operating system. It provides a real-time API to view and control hosts, processes, and containers. The API allows traversal and manipulation of the cluster as a unified namespace. The document outlines the API, including command line usage and a Go client package. It then describes how to build a job scheduler service using the Circuit API, including designing the state, handling events, and running jobs on hosts. The vision is for Circuit to enable easy sharing of systems and for any program to take on different roles by executing as a recursive process tree on the cluster.
Lecture 7: Introduction to Quantum Chemical Simulation graduate course taught at MIT in Fall 2014 by Heather Kulik. This course covers: wavefunction theory, density functional theory, force fields and molecular dynamics and sampling.
This document discusses different performance needs for development versus production environments. In development, performance is less critical and single-core usage is common, while in production, multi-core usage and optimized garbage collection are important for throughput and response times. It also summarizes the results of running Rails' test suite, showing over 16,000 tests with over 56,000 assertions passing with no failures or errors.
Nadav Markus goes over the path from a simple crash POC provided by Google Project Zero (for CVE-2015-7547), to a fully weaponized exploit.
He explores how an attacker can utilize the behavior of the Linux kernel in order to bypass ASLR, allowing an attacker to remotely execute code on vulnerable targets.
Agenda:
The Linux kernel has multiple "tracers" built-in, with various degrees of support for aggregation, dynamic probes, parameter processing, filtering, histograms, and other features. Starting from the venerable ftrace, introduced in kernel 2.6, all the way through eBPF, which is still under development, there are many options to choose from when you need to statically instrument your software with probes, or diagnose issues in the field using the system's dynamic probes. Modern tools include SystemTap, Sysdig, ktap, perf, bcc, and others. In this talk, we will begin by reviewing the modern tracing landscape -- ftrace, perf_events, kprobes, uprobes, eBPF -- and what insight into system activity these tools can offer. Then, we will look at specific examples of using tracing tools for diagnostics: tracing a memory leak using low-overhead kmalloc/kfree instrumentation, diagnosing a CPU caching issue using perf stat, probing network and block I/O latency distributions under load, or merely snooping user activities by capturing terminal input and output.
Speaker:
Sasha is the CTO of Sela Group, a training and consulting company based in Israel that employs over 400 developers world-wide. Most of Sasha's work revolves around performance optimization, production debugging, and low-level system diagnostics, but he also dabbles in mobile application development on iOS and Android. Sasha is the author of two books and three Pluralsight courses, and a contributor to multiple open-source projects. He blogs at http://blog.sashag.net.
This talk is all about the Berkeley Packet Filters (BPF) and their uses in Linux.
Agenda:
* What is a BPF and why do we need it?
* Writing custom BPFs
* Notes on BPF implementation in the kernel
* Usage examples: SOCKET_FILTER & seccomp
Speaker:
Kfir Gollan, senior embedded software developer, Linux kernel hacker and software team leader.
Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.
Linux kernel tracing superpowers in the cloudAndrea Righi
The Linux 4.x series introduced a new powerful engine of programmable tracing (BPF) that allows to actually look inside the kernel at runtime. This talk will show you how to exploit this engine in order to debug problems or identify performance bottlenecks in a complex environment like a cloud. This talk will cover the latest Linux superpowers that allow to see what is happening “under the hood” of the Linux kernel at runtime. I will explain how to exploit these “superpowers” to measure and trace complex events at runtime in a cloud environment. For example, we will see how we can measure latency distribution of filesystem I/O, details of storage device operations, like individual block I/O request timeouts, or TCP buffer allocations, investigating stack traces of certain events, identify memory leaks, performance bottlenecks and a whole lot more.
Kernel Recipes 2019 - CVEs are dead, long live the CVE!Anne Nicolas
For the Linux kernel, CVEs do not work at all given the rate of fixes being applied and rapidly backported and pushed to users through a huge variety of different ways. The average “request to fix” date for Linux CVEs is -100 days, showing that either no one cares about CVEs for Linux, or engineers are using them to game their internal release processes, or no one happens to notice when the kernel developers resolve an issue, or all of the above. This talk will go into the problems with CVEs when it comes to a fast moving project like Linux, and show the decentralized solution that we have been using for the past 14 years instead. All other open source projects are encouraged to use these same methods to help resolve the problems that CVEs have.
Kernel Recipes 2016 - Kernel documentation: what we have and where it’s goingAnne Nicolas
The Linux kernel features an extensive array of, to put it kindly, somewhat disorganized documentation. A significant effort is underway to make things better, though. This talk will review the state of kernel documentation, cover the changes that are being made (including the adoption of a new system for formatted documentation), and discuss how interested developers can help.
Jonathan Corbet, LWN.net
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021Valeriy Kravchuk
Bpftrace is a relatively new eBPF-based open source tracer for modern Linux versions (kernels 5.x.y) that is useful for analyzing production performance problems and troubleshooting software. Basic usage of the tool, as well as bpftrace one liners and advanced scripts useful for MariaDB DBAs are presented. Problems of MariaDB Server dynamic tracing with bpftrace and some possible solutions and alternative tracing tools are discussed.
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomValeriy Kravchuk
bpftrace is a relatively new open source tracer for modern Linux (kernels 5.x.y) that may help to troubleshoot performance issues in production as well as to get insights on how software really works. I use it for a couple of years and would like to present more details on how to do it efficiently, including but not limited to adding user probes to different lines of the code inside functions, checking values of local variables and using bpftrace as a code coverage tool.
All of Your Network Monitoring is (probably) Wrongice799
The document discusses the challenges of network monitoring due to complexity in systems and lack of standardization. It notes that drivers and tools like ethtool may report statistics differently or incompletely between hardware. This makes it difficult to understand monitoring data and diagnose issues from graphs alone without deep knowledge of underlying driver and hardware implementations.
The document provides an overview and outline of a 2-day workshop on Network Simulator 3 (NS3). Day 1 will cover introducing NS3, installing it, configuring it with Eclipse, understanding the architecture, and reading code samples. Day 2 focuses on mobility and wireless models, writing wireless network code, analyzing the AODV routing protocol, attributes, tracing, and using Gnuplot. The document also summarizes NS3's features, how to install it on Ubuntu, prerequisites, building NS3 projects, testing installations, running examples, and configuring NS3 with Eclipse and Doxygen.
Après avoir fait ce talk à la conférence NSSpain, Simone Civetta va nous expliquer sur quelles métriques il est possible de se baser pour évaluer la qualité d’un code source. Cette question étant toujours sujette à débat, préparez vos arguments !
Kselftest is a developer-friendly test framework and set of tests for the Linux kernel. It aims to help developers test the kernel more easily and frequently. Tests are contained in the kernel source code and can be built, run, installed, and packaged quickly and easily. Writing new tests and using the test code as documentation makes kselftest a good starting point for new kernel developers.
The document discusses various topics related to tuning the Java Virtual Machine (JVM) for performance, including:
1. Hotspot compiler options like method inlining that can improve performance.
2. Threading models on Solaris like M:N and 1:1 and how tuning thread-related JVM options can significantly impact throughput.
3. Memory and garbage collection tuning like selecting the right GC algorithm, tuning heap sizes, and analyzing GC logs to identify bottlenecks and optimize full GC frequency and duration.
Golang Performance : microbenchmarks, profilers, and a war storyAerospike
Slides for Brian Bulkowski's talk about Golang performance:
microbenchmarks, profilers, and a war story about optimizing the Aerospike Database Go client.
http://www.meetup.com/Go-lang-Developers-NYC/events/216650022/
The Simple Scheduler in Embedded System @ OSDC.TW 2014Jian-Hong Pan
The document describes a simple scheduler module implemented in C for embedded systems. It breaks processes into small jobs represented by functions that are scheduled in a first-in, first-out queue without preemption. This allows embedding an operating system concept into simple systems using only functions and a ready queue. Interrupts can add jobs to the queue. The scheduler and example oscilloscope application demonstrate scheduling without process state using only callbacks.
[CCC-28c3] Post Memory Corruption Memory AnalysisMoabi.com
The document summarizes the Post Memory Corruption Memory Analysis (PMCMA) tool. PMCMA allows finding and testing exploitation scenarios resulting from invalid memory accesses. It provides a roadmap to exploitation without generating exploit code. The tool analyzes programs after crashes to overwrite memory locations in forked processes and test impact on execution flow.
[231] the simplicity of cluster apps with circuitNAVER D2
This document discusses Circuit, a lightweight cluster operating system. It provides a real-time API to view and control hosts, processes, and containers. The API allows traversal and manipulation of the cluster as a unified namespace. The document outlines the API, including command line usage and a Go client package. It then describes how to build a job scheduler service using the Circuit API, including designing the state, handling events, and running jobs on hosts. The vision is for Circuit to enable easy sharing of systems and for any program to take on different roles by executing as a recursive process tree on the cluster.
Lecture 7: Introduction to Quantum Chemical Simulation graduate course taught at MIT in Fall 2014 by Heather Kulik. This course covers: wavefunction theory, density functional theory, force fields and molecular dynamics and sampling.
This document discusses different performance needs for development versus production environments. In development, performance is less critical and single-core usage is common, while in production, multi-core usage and optimized garbage collection are important for throughput and response times. It also summarizes the results of running Rails' test suite, showing over 16,000 tests with over 56,000 assertions passing with no failures or errors.
Nadav Markus goes over the path from a simple crash POC provided by Google Project Zero (for CVE-2015-7547), to a fully weaponized exploit.
He explores how an attacker can utilize the behavior of the Linux kernel in order to bypass ASLR, allowing an attacker to remotely execute code on vulnerable targets.
Agenda:
The Linux kernel has multiple "tracers" built-in, with various degrees of support for aggregation, dynamic probes, parameter processing, filtering, histograms, and other features. Starting from the venerable ftrace, introduced in kernel 2.6, all the way through eBPF, which is still under development, there are many options to choose from when you need to statically instrument your software with probes, or diagnose issues in the field using the system's dynamic probes. Modern tools include SystemTap, Sysdig, ktap, perf, bcc, and others. In this talk, we will begin by reviewing the modern tracing landscape -- ftrace, perf_events, kprobes, uprobes, eBPF -- and what insight into system activity these tools can offer. Then, we will look at specific examples of using tracing tools for diagnostics: tracing a memory leak using low-overhead kmalloc/kfree instrumentation, diagnosing a CPU caching issue using perf stat, probing network and block I/O latency distributions under load, or merely snooping user activities by capturing terminal input and output.
Speaker:
Sasha is the CTO of Sela Group, a training and consulting company based in Israel that employs over 400 developers world-wide. Most of Sasha's work revolves around performance optimization, production debugging, and low-level system diagnostics, but he also dabbles in mobile application development on iOS and Android. Sasha is the author of two books and three Pluralsight courses, and a contributor to multiple open-source projects. He blogs at http://blog.sashag.net.
This talk is all about the Berkeley Packet Filters (BPF) and their uses in Linux.
Agenda:
* What is a BPF and why do we need it?
* Writing custom BPFs
* Notes on BPF implementation in the kernel
* Usage examples: SOCKET_FILTER & seccomp
Speaker:
Kfir Gollan, senior embedded software developer, Linux kernel hacker and software team leader.
Docker is an open-source project to easily create lightweight, portable, self-sufficient containers from any application. The same container that a developer builds and tests on a laptop can run at scale, in production, on VMs, bare metal, OpenStack clusters, public clouds and more.
Linux kernel tracing superpowers in the cloudAndrea Righi
The Linux 4.x series introduced a new powerful engine of programmable tracing (BPF) that allows to actually look inside the kernel at runtime. This talk will show you how to exploit this engine in order to debug problems or identify performance bottlenecks in a complex environment like a cloud. This talk will cover the latest Linux superpowers that allow to see what is happening “under the hood” of the Linux kernel at runtime. I will explain how to exploit these “superpowers” to measure and trace complex events at runtime in a cloud environment. For example, we will see how we can measure latency distribution of filesystem I/O, details of storage device operations, like individual block I/O request timeouts, or TCP buffer allocations, investigating stack traces of certain events, identify memory leaks, performance bottlenecks and a whole lot more.
Kernel Recipes 2019 - CVEs are dead, long live the CVE!Anne Nicolas
For the Linux kernel, CVEs do not work at all given the rate of fixes being applied and rapidly backported and pushed to users through a huge variety of different ways. The average “request to fix” date for Linux CVEs is -100 days, showing that either no one cares about CVEs for Linux, or engineers are using them to game their internal release processes, or no one happens to notice when the kernel developers resolve an issue, or all of the above. This talk will go into the problems with CVEs when it comes to a fast moving project like Linux, and show the decentralized solution that we have been using for the past 14 years instead. All other open source projects are encouraged to use these same methods to help resolve the problems that CVEs have.
Kernel Recipes 2016 - Kernel documentation: what we have and where it’s goingAnne Nicolas
The Linux kernel features an extensive array of, to put it kindly, somewhat disorganized documentation. A significant effort is underway to make things better, though. This talk will review the state of kernel documentation, cover the changes that are being made (including the adoption of a new system for formatted documentation), and discuss how interested developers can help.
Jonathan Corbet, LWN.net
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021Valeriy Kravchuk
Bpftrace is a relatively new eBPF-based open source tracer for modern Linux versions (kernels 5.x.y) that is useful for analyzing production performance problems and troubleshooting software. Basic usage of the tool, as well as bpftrace one liners and advanced scripts useful for MariaDB DBAs are presented. Problems of MariaDB Server dynamic tracing with bpftrace and some possible solutions and alternative tracing tools are discussed.
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomValeriy Kravchuk
bpftrace is a relatively new open source tracer for modern Linux (kernels 5.x.y) that may help to troubleshoot performance issues in production as well as to get insights on how software really works. I use it for a couple of years and would like to present more details on how to do it efficiently, including but not limited to adding user probes to different lines of the code inside functions, checking values of local variables and using bpftrace as a code coverage tool.
All of Your Network Monitoring is (probably) Wrongice799
The document discusses the challenges of network monitoring due to complexity in systems and lack of standardization. It notes that drivers and tools like ethtool may report statistics differently or incompletely between hardware. This makes it difficult to understand monitoring data and diagnose issues from graphs alone without deep knowledge of underlying driver and hardware implementations.
The document provides an overview and outline of a 2-day workshop on Network Simulator 3 (NS3). Day 1 will cover introducing NS3, installing it, configuring it with Eclipse, understanding the architecture, and reading code samples. Day 2 focuses on mobility and wireless models, writing wireless network code, analyzing the AODV routing protocol, attributes, tracing, and using Gnuplot. The document also summarizes NS3's features, how to install it on Ubuntu, prerequisites, building NS3 projects, testing installations, running examples, and configuring NS3 with Eclipse and Doxygen.
Après avoir fait ce talk à la conférence NSSpain, Simone Civetta va nous expliquer sur quelles métriques il est possible de se baser pour évaluer la qualité d’un code source. Cette question étant toujours sujette à débat, préparez vos arguments !
The document discusses an OpenCV C++ workshop presented by Lentin Joseph. It provides an overview of OpenCV, including that it is an open source computer vision library started in 1999. It then covers installing OpenCV from source or Ubuntu packages, setting it up in Eclipse, and various OpenCV modules and applications like gesture recognition, segmentation, and face detection. Examples are provided of OpenCV APIs for reading images and video, image processing techniques, and contour detection.
Cypress is an open source, front end testing tool built for modern web applications. It uses JavaScript to write automated end-to-end tests that run directly in the browser engine. Unlike Selenium which runs outside the browser, Cypress operates inside the browser to listen and modify behavior. Cypress makes testing simple through its intuitive API, fast speeds, and ability to work on any frontend framework. The document outlines Cypress' architecture, features, limitations, installation process, project structure, and how to write tests using constructs like describe, it, before, and assertions.
Bgoug 2019.11 test your pl sql - not your patienceJacek Gebal
This document discusses unit testing in PL/SQL. It emphasizes that testing is important to prevent bugs, make code changeable, prove requirements are met, and document code. The document recommends testing all logic, exceptions, and data. Tests should be automated and run early and often using a test framework like utPLSQL. utPLSQL allows writing isolated tests using annotations and matchers to make assertions. Tests can be organized into suites with contexts and run as part of continuous integration pipelines.
Property-based testing an open-source compiler, pflua (FOSDEM 2015)Igalia
By Katerina Barone-Adesi.
Discover property-based testing, and see how it works on a real project, the pflua compiler.
How do you find a lot of non-obvious bugs in an afternoon? Write a property that should always be true (like "this code should have the same result before and after it's optimized"), generate random valid expressions, and study the counter-examples!
Property-based testing is a powerful technique for finding bugs quickly. It can partly replace unit tests, leading to a more flexible test suite that generates more cases and finds more bugs in less time.
It's really quick and easy to get started with property-based testing. You can use existing tools like QuickCheck, or write your own: Andy Windo and I wrote pflua-quickcheck and found a half-dozen bugs with it in one afternoon, using pure Lua and no external libraries.
In this talk, I will introduce property-based testing, demonstrate a tool for using it in Lua - and how to write your own property-based testing tool from scratch, and explain how simple properties found bugs in pflua.
(c) 2015 FOSDEM VZW
CC BY 2.0 BE
https://archive.fosdem.org/2015/
[HKOSCon x COSCUP 2020][20200801][Ansible: From VM to Kubernetes]Wong Hoi Sing Edison
By using Ansible for DevOps, we could manage both VM, Docker image provision, Kubernetes and CephFS provision, or even Kubernetes Pod runtime management.
prohuddle-utPLSQL v3 - Ultimate unit testing framework for OracleJacek Gebal
Fundamentals of Unit Testing and TDD as a practice and presentation of core features available with utPLSQL v3.
Unit testing for Oracle Databases and PLSQL programming language.
Moving from Jenkins 1 to 2 declarative pipeline adventuresFrits Van Der Holst
T-Dose 2017 presentation, Sunday 19 November 2017. Adventures building a declarative pipeline script for a traditional (non-java/non-cloud) installable windows/Linux application. Video will hopefully be available later.
This document summarizes a workshop on .NET debugging techniques. The workshop covers debugging production issues, analyzing system and application performance, and automating debugging processes. It discusses tools like Procdump, DebugDiag, and Windows debugging tools. It also covers debugging techniques like generating dump files, using Event Tracing for Windows (ETW) to collect traces, and analyzing traces with tools like PerfView. The goal is to help integrate automatic error analysis and triage into development processes.
How do we go from your Java code to the CPU assembly that actually runs it? Using high level constructs has made us forget what happens behind the scenes, which is however key to write efficient code.
Starting from a few lines of Java, we explore the different layers that constribute to running your code: JRE, byte code, structure of the OpenJDK virtual machine, HotSpot, intrinsic methds, benchmarking.
An introductory presentation to these low-level concerns, based on the practical use case of optimizing 6 lines of code, so that hopefully you to want to explore further!
Presentation given at the Toulouse (FR) Java User Group.
Video (in french) at https://www.youtube.com/watch?v=rB0ElXf05nU
Slideshow with animations at https://docs.google.com/presentation/d/1eIcROfLpdTU2_Z_IKiMG-AwqZGZgbN1Bs2E0nGShpbk/pub?start=true&loop=false&delayms=60000
This document discusses principles for achieving high availability in Drupal applications. It recommends using version control for all code and configuration, deploying artifacts rather than code directly, and configuring infrastructure and monitoring automation through tools like Chef and Puppet. It also stresses the importance of redundancy across multiple availability zones for critical services and caching, dealing with issues like unique IDs, replication conflicts, and cache flushing across nodes. The document advocates measuring systems thoroughly with logging, metrics and alerts, and contributing optimization work back to the open source community.
The document discusses developing Groovy scripts securely and productively in the cloud for Oracle Application Developer Framework (ADF). It outlines using Groovy AST transformations to add debugging capabilities and runtime security checks when executing scripts in the cloud. Caching is also discussed to improve performance of compiling thousands of scripts across many applications. The implementation transforms the AST to wrap method calls and inject breakpoints while limiting access to restricted APIs.
The document discusses the history of build tools and outlines a roadmap for sbt 1.0 focused on stability and modularization. It introduces sbt-server as a way to centralize build tasks and allow multiple clients to interact with the build. Key points of the sbt-server design include running tasks in a centralized queue, handling reconnects, using a versioned protocol for communication, and supporting background jobs and input. The document also discusses bringing existing sbt plugins onto sbt-server without breaking functionality.
Semi-Automatic Code Cleanup with Clang-TidyMarkus Werle
Clang-tidy is a static analysis tool that finds typical programming errors, style violations, and other problems in C++ code. It contains a wide range of checks and can automatically fix some issues. Checks can be enabled and configured via command line options. Clang-tidy works by parsing compilation databases generated by build tools like CMake. It analyzes each translation unit and applies the selected checks. The modernize group of checks helps update code to use modern C++ features. Clang-tidy is very useful but installing and configuring the latest version from source can be challenging.
Towards Continuous Deployment with DjangoRoger Barnes
It's no secret that python is fantastic when it comes to rapid prototyping and development. When it comes to deploying a web application, the road to glory isn't as well paved and navigating the array of techniques and tools can be daunting.
This talk will address the advantages of continuous deployment, the success factors involved and the tools available, mainly focusing on experiences with Django web development.
Similar to NovaProva, a new generation unit test framework for C programs (20)
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
DDS Security Version 1.2 was adopted in 2024. This revision strengthens support for long runnings systems adding new cryptographic algorithms, certificate revocation, and hardness against DoS attacks.
SOCRadar's Aviation Industry Q1 Incident Report is out now!
The aviation industry has always been a prime target for cybercriminals due to its critical infrastructure and high stakes. In the first quarter of 2024, the sector faced an alarming surge in cybersecurity threats, revealing its vulnerabilities and the relentless sophistication of cyber attackers.
SOCRadar’s Aviation Industry, Quarterly Incident Report, provides an in-depth analysis of these threats, detected and examined through our extensive monitoring of hacker forums, Telegram channels, and dark web platforms.
WhatsApp offers simple, reliable, and private messaging and calling services for free worldwide. With end-to-end encryption, your personal messages and calls are secure, ensuring only you and the recipient can access them. Enjoy voice and video calls to stay connected with loved ones or colleagues. Express yourself using stickers, GIFs, or by sharing moments on Status. WhatsApp Business enables global customer outreach, facilitating sales growth and relationship building through showcasing products and services. Stay connected effortlessly with group chats for planning outings with friends or staying updated on family conversations.
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
SMS API Integration in Saudi Arabia| Best SMS API ServiceYara Milbes
Discover the benefits and implementation of SMS API integration in the UAE and Middle East. This comprehensive guide covers the importance of SMS messaging APIs, the advantages of bulk SMS APIs, and real-world case studies. Learn how CEQUENS, a leader in communication solutions, can help your business enhance customer engagement and streamline operations with innovative CPaaS, reliable SMS APIs, and omnichannel solutions, including WhatsApp Business. Perfect for businesses seeking to optimize their communication strategies in the digital age.
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemPeter Muessig
Learn about the latest innovations in and around OpenUI5/SAPUI5: UI5 Tooling, UI5 linter, UI5 Web Components, Web Components Integration, UI5 2.x, UI5 GenAI.
Recording:
https://www.youtube.com/live/MSdGLG2zLy8?si=INxBHTqkwHhxV5Ta&t=0
Zoom is a comprehensive platform designed to connect individuals and teams efficiently. With its user-friendly interface and powerful features, Zoom has become a go-to solution for virtual communication and collaboration. It offers a range of tools, including virtual meetings, team chat, VoIP phone systems, online whiteboards, and AI companions, to streamline workflows and enhance productivity.
8 Best Automated Android App Testing Tool and Framework in 2024.pdfkalichargn70th171
Regarding mobile operating systems, two major players dominate our thoughts: Android and iPhone. With Android leading the market, software development companies are focused on delivering apps compatible with this OS. Ensuring an app's functionality across various Android devices, OS versions, and hardware specifications is critical, making Android app testing essential.
E-commerce Application Development Company.pdfHornet Dynamics
Your business can reach new heights with our assistance as we design solutions that are specifically appropriate for your goals and vision. Our eCommerce application solutions can digitally coordinate all retail operations processes to meet the demands of the marketplace while maintaining business continuity.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Łukasz Chruściel
No one wants their application to drag like a car stuck in the slow lane! Yet it’s all too common to encounter bumpy, pothole-filled solutions that slow the speed of any application. Symfony apps are not an exception.
In this talk, I will take you for a spin around the performance racetrack. We’ll explore common pitfalls - those hidden potholes on your application that can cause unexpected slowdowns. Learn how to spot these performance bumps early, and more importantly, how to navigate around them to keep your application running at top speed.
We will focus in particular on tuning your engine at the application level, making the right adjustments to ensure that your system responds like a well-oiled, high-performance race car.
What is Augmented Reality Image Trackingpavan998932
Augmented Reality (AR) Image Tracking is a technology that enables AR applications to recognize and track images in the real world, overlaying digital content onto them. This enhances the user's interaction with their environment by providing additional information and interactive elements directly tied to physical images.
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
NovaProva, a new generation unit test framework for C programs
1. novaprova
a new generation unit test
framework for C programs
www.novaprova.org
Greg Banks <gnb@fastmail.fm>
2. Overview
● Why Did I Write NovaProva?
● Design Philosophy & Features
● Tutorial + How It Works
● Remaining Work
● End Matter
3. Why Did I Write NovaProva?
● scratching my own itch!
● my day job is the Cyrus IMAP server
– which is written in C (K&R in some places)
– and is large
– and old
– and complex
– and had ZERO buildable tests when I started
5. Testing Cyrus
● I added system tests using Perl
– http://git.cyrusimap.org/cassandane/
● I added unit tests using the CUnit library
– because it's commonly available
– supports C (no C++)
– the first few tests were easy
– but they got harder and harder
6. Is Cyrus Tested Enough?
● code-to-test ratio metric
– easily measurable; just enough meaning
● "Code-to-test ratios above 1:2 is a smell,
above 1:3 is a stink."
– David H. Hansson, creator of Ruby On Rails
● 1:0 is too little – no tests at all
● sweet spot 1:1 to 1:2
– from the zeitgeist on stackexchange.com
7. Some Example C projects
sweet
spot
worse
sweet
spot
better
8. From Which We Can Conclude
● the SQLite folks need a hobby
● lots of C software is “under” tested
● Cyrus is very under tested
● why!?
● in my experience writing & running more than
a few CUnit tests is very hard
● need a better CUnit – NovaProva!
9. Design Philosophy
● fully support C as well as C++
– do not rely on C++ features for discovery or
reflection
– tests buildable without a C++ compiler
● choose power over portability
– portability is important
– but for tests it's better to have good tests on
one platform than bad tests on all platforms
10. Design Philosophy (2)
● choose your convenience over my laziness
– I put the work into the framework so you don't
have to put it into the tests
– simplify the tedious parts of testing
● choose correct over fast
– slow tests are annoying
– but remotely debugging after shipping is much
more annoying
11. Design Philosophy (3)
● choose best practice as the default
– maximise test isolation
– maximise failure mode detection
● have the courage to do “impossible” things
12. Features
● writing tests is easy
● build integration is easy
● tests are powerful
● test running is reliable
● integrating with other tools is easy
13. Writing Tests Is Easy
● test functions are void (void)
– returning normally is a success
● use familiar xUnit-like assertion macros
– 1st
failure terminates the test
– like *_FATAL() semantics in CUnit
14. Example 01_simple: test
/* mytest.c */
#include <np.h>
#include "mycode.h"
static void test_simple(void)
{
int r;
r = myatoi("42");
NP_ASSERT_EQUAL(r, 42);
} assert correct result
test function
NovaProva header
call Code Under Test
Code Under Test header
15. Writing The Main Is Easy
● no need to register test functions
– just name your test function test_foobar()
– may be static
● fully automatic test discovery at runtime
– uses reflection
16. Example 01_simple: main
/* testrunner.c */
#include <stdlib.h>
#include <np.h>
int main(int argc, char **argv)
{
int ec = 0;
np_runner_t *runner = np_init();
ec = np_run_tests(runner, NULL);
np_done(runner);
exit(ec);
} shut down the library
run all tests
NovaProva header
initialise the library
17. How Does Reflection Work
● reflection: a program detects facts about
(other parts of) itself
– all modern languages do this
● “C can't do reflection”
– there is no standard API
– the compiler doesn't write the info into .o files
● yes it does: -g debug information
● but, that's not standard!
● yes it is: DWARF
18. How Does Reflection Work (2)
● the case for DWARF
– standard – documents at dwarfstd.org
– used with ELF on Linux & Solaris
– used with Mach objects on MacOS
– compilers already generate it
● using -g easier than patching cc
● but, it's only for the debugger!
– it's a general purpose format
– describes many artifacts of the compiler's
output and maps to source
19. How Does Reflection Work (3)
● so I created a reflection API
● provides a high-level API
● reads DWARF info
– read /proc/self/exe to find pathname
– call dl_iterate_phdr() to walk the runtime
linker's map of objects
– use libbfd to find ELF sections
– use mmap() to map the .debug_* sections
– lazily decode the mmap'd DWARF info
20. Runtime Test Discovery
● once we have reflection, it's fairly easy
● walk all functions in all compile_units
– compare against regexp /^test_(.*)$/
– test name is the 1st
submatch
– check function has void return & args
– testnode name = CU's pathname + test name
– make a new testnode, creating ancestors
● prune common nodes from root
● mocks & parameters found the same way
21. Build Integration Is Easy
● just a library, no build-time magic
– fully C-friendly API
– uses C++ internally
– but you don't need to compile or link using C++
● easy to drop into your project
– pkg-config .pc file
– PKG_CHECK_MODULES in automake
● need to build tests with -g
– but not the Code Under Test
22. Building Example 01_simple
# Makefile
NOVAPROVA_CFLAGS= $(shell pkg-config --cflags novaprova)
NOVAPROVA_LIBS= $(shell pkg-config --libs novaprova)
CFLAGS= -g $(NOVAPROVA_CFLAGS)
check: testrunner
./testrunner
TEST_SOURCE= mytest.c
TEST_OBJS= $(TEST_SOURCE:.c=.o)
testrunner: testrunner.o $(TEST_OBJS) $(MYCODE_OBJS)
$(LINK.c) -o $@ testrunner.o $(TEST_OBJS)
$(MYCODE_OBJS) $(NOVAPROVA_LIBS)
the check: target builds & runs
pkg-config tells us the right flags
need to build with -g
very standard link rule for testrunner
23. Running Tests Is Reliable
● runs tests under Valgrind
– detects many failure modes of C code
– turns them into graceful test failures
● strong test isolation
– uses UNIX process model
– forks a process per test
– if one test fails, keeps running other tests
– allows for running in parallel
– allows for reliable timeouts
27. Running Example 01_simple
% make check
./testrunner
[0.000] np: starting valgrind
np: NovaProva Copyright (c) Gregory Banks
np: Built for O/S linux architecture x86
np: running
np: running: "mytest.simple"
PASS mytest.simple
np: 1 run 0 failed
check: target builds & runs
automatically starts Valgrind
By default runs
all tests serially
post-run summary
28. How NP Valgrinds Itself
● Valgrind should be easy & the default, with no
build system changes
– Valgrind is a CPU+kernel simulator
– you can't just start Valgrind on a running
process
● build a Valgrind command line in the library
and execv() - easy!
– downside: main() is run twice
– major downside: Valgrind exec loop
29. How NP Valgrinds Itself (2)
● Valgrind has an API you can use
– #include <valgrind/valgrind.h>
– macros that compile to magical NOP
instruction sequences
– these do nothing on a real CPU, but Valgrind
does special things
● predicate RUNNING_ON_VALGRIND
– returns true iff the process is running in
Valgrind
– so the library checks that
30. How NP Valgrinds Itself (3)
● to run Valgrind we need argv[]
– original, before any getopt() processing
– to pass down to the 2nd
main()
– for maximum convenience and reliability,
shouldn't expect main() to pass the correct
argv[] down
● global variable _dl_argv
– undocumented, undeclared, defined in the
runtime linker
– set to main()'s argv[], before main()
31. Parallel Running
● default mode is to run tests serially
● optionally can run tests in parallel
● call np_set_concurrency() in main
– 0 = use all the online CPUs on the machine
32. Example 02_parallel
int main(int argc, char **argv)
{
…
int concurrency = -1;
np_runner_t *runner;
…
while ((c = getopt(argc, argv, "j:")) >= 0)
{
switch (c)
{
case 'j':
concurrency = atoi(optarg);
…
runner = np_init();
if (concurrency >= 0)
np_set_concurrency(runner, concurrency);
ec = np_run_tests(runner, NULL);
parse -j option
33. Running Example 02_parallel
./testrunner -j4
…
np: running
np: running: "mytest.000"
np: running: "mytest.001"
np: running: "mytest.002"
np: running: "mytest.003"
Running test 0
Running test 1
Running test 2
Running test 3
Finished test 0
Finished test 1
Finished test 2
Finished test 3
PASS mytest.000
PASS mytest.002
PASS mytest.003
PASS mytest.001
np: 4 run 0 failed
request 4 tests in parallel
runs all tests
in parallel
post-run summary
34. Using GDB
● NP detects when it's running in gdb
– automatically disables test timeout
– automatically disables Valgrind
● but you have to set some gdb options, sorry!
– always runs the test in a fork()ed child
– set follow-fork-mode child
– set detach-on-fork off
35. Debugging Example 01_simple
% cat .gdbinit
set follow-fork-mode child
set detach-on-fork off
% gdb testrunner
(gdb) bre myatoi
Breakpoint 1 at 0x804ad96: file mycode.c, line 21.
(gdb) run
Starting program: …
np: being debugged by gdb
np: disabling Valgrind under debugger
np: NovaProva Copyright (c) Gregory Banks
np: Built for O/S linux architecture x86
np: being debugged by gdb
np: disabling test timeouts under debugger
np: running
np: running: "mytest.simple"
Breakpoint 1, myatoi (s=0x807b1c8 "42") at mycode.c:21
21 int v = 0;
set a breakpoint
some .gdbinit magic
Valgrind is disabled
timeouts are disabled
36. How NP Detects GDB
● sometimes the library needs to know if it's
running under GDB
– need to disable test timeouts
– need to avoid running self under Valgrind
because gdb & Valgrind don't play together
● on Linux, gdb uses ptrace() to attach itself to a
process
– a process knows if it's being traced
– /proc/$pid/status shows "TracerPid:"
37. How NP Detects GDB (2)
● read /proc/self/status to see if we're ptraced
– downside: other utilities like strace also use
ptrace()
● we also use /proc/$pid/cmdline to discover the
tracer's argv[0]
– and compare this to a whitelist of debugger
executables
– yes there is /proc/$pid/exe symlink, but it's not
always readable
38. Using Jenkins CI
● Jenkins reads, tracks & displays test results
– in jUnit XML format
● http://ci.cyrusimap.org/
39. Using Jenkins CI (2)
● NP optionally emits jUnit XML report
● call np_set_output_format() in main
– an XML file is written for each suite
– to reports/TEST-$suite.xml
40. Example 03_jenkins
int main(int argc, char **argv)
{
int ec = 0;
const char *output_format = 0;
np_runner_t *runner;
…
while ((c = getopt(argc, argv, "f:")) >= 0)
{
switch (c)
{
case 'f':
output_format = optarg;
break;
…
runner = np_init();
if (output_format)
np_set_output_format(runner, output_format);
parse the -f option
name of the
output format
41. Running Example 03_jenkins
% mkdir reports
% ./testrunner -f junit
[0.000] np: starting valgrind
np: NovaProva Copyright (c) Gregory Banks
np: Built for O/S linux architecture x86
% ls reports/
TEST-mytest.xml
% xmllint --format reports/TEST-mytest.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="mytest" failures="0" tests="1"
hostname="…" timestamp="2013-01-28T12:15:39" errors="0"
time="0.882">
<properties/>
<testcase name="simple" classname="simple"
time="0.882"/>
<system-out/>
<system-err/>
</testsuite>
Use the -f option
instead a new XML file
no post-run
summary
this doesn't work yet
42. Fixtures & N/A
● supports a Not Applicable test result
– so a test can decide that preconditions aren't
met
– counted separately from passes and failures
● supports fixtures
– set_up function is called before every test
– tear_down function is called after every test
– discovered at runtime using reflection
– will be fixed in 1.2, sorry
43. Example 04_fixtures
static int set_up(void)
{
fprintf(stderr, "Setting up fixturesn");
return 0;
}
static int tear_down(void)
{
fprintf(stderr, "Tearing down fixturesn");
return 0;
}
just call a function set_up
and tear_down
44. Running Example 04_fixtures
np: running
np: running: "mytest.one"
Setting up fixtures
Running test_one
Finished test_one
Tearing down fixtures
PASS mytest.one
np: running: "mytest.two"
Setting up fixtures
Running test_two
Finished test_two
Tearing down fixtures
PASS mytest.two
np: 2 run 0 failed
set_up runs before test
tear_down runs after test
each test
45. Tests Are A Tree
● xUnit implementations have a 2-level
organisation
– test – the smallest runnable element
– suite – group of tests
● software just isn't that simple anymore
● NP uses an arbitrary depth tree of testnodes
– single root testnode
– each testnode has a full pathname
– separated by '.'
46. Tests Are A Tree (2)
● testnodes may have any of
– a runnable test function
– child testnodes
– fixture functions & other resources
● apply to the node & all descendants
● tree is built automatically at runtime
– test functions → leaf nodes
– C source filenames → nodes above that
– directory path name → nodes above those
– redundant path down from / pruned
47. Tests Are A Tree (3)
● tests are named in a way which naturally
reflects your source code organisation
● unique test names, no effort
● flexible scoping/containment mechanism
49. Running Example 05_tree
np: running
np: running:
"05_tree.startrek.tng.federation.enterprise.torpedoes"
Testing photon torpedoes
PASS
05_tree.startrek.tng.federation.enterprise.torpedoes
np: running:
"05_tree.startrek.tng.klingons.neghvar.disruptors"
Testing disruptors
PASS 05_tree.startrek.tng.klingons.neghvar.disruptors
np: running:
"05_tree.starwars.episode4.rebels.xwing.lasers"
Testing laser cannon
PASS 05_tree.starwars.episode4.rebels.xwing.lasers
np: 3 run 0 failed
function
.c filename
directory path name
50. Function Mocking
● mocking a function = arrange for Code under
Test to call a special test function instead of
some normal part of CuT
● dynamic: inserted at runtime not link time
– uses a breakpoint-like mechanism
– when running under gdb need to do handle
SIGSEGV nostop noprint
● mocks may be setup declaratively
– name a function mock_foo() & it mocks foo()
51. Example 06_mock: CuT
int myatoi(const char *s)
{
int v = 0;
for ( ; *s ; s++)
{
v *= 10;
v += mychar2int(*s);
}
return v;
}
int mychar2int(int c)
{
return (c - '0');
}
this function
this one
calls
52. Example 06_mock: Test
static void test_simple(void)
{
int r;
r = myatoi("42");
NP_ASSERT_EQUAL(r, 42);
}
int mock_mychar2int(int c)
{
fprintf(stderr, "Mocked mychar2int('%c') calledn", c);
return (c - '0');
}
test calls myatoi
which calls
mychar2int
this mocks
mychar2int
53. Running Example 06_mock
./testrunner
[0.000] np: starting valgrind
np: NovaProva Copyright (c) Gregory Banks
np: Built for O/S linux architecture x86
np: running
np: running: "mytest.simple"
Mocked mychar2int('4') called
Mocked mychar2int('2') called
PASS mytest.simple
np: 1 run 0 failed
the mock is
called instead
54. More On Function Mocking
● mocks may be added at runtime
– by name or by function pointer
– from tests or fixtures
– so you can mock for only part of a test
● mocks may be attached to any testnode
– automatically installed before any test below
that node starts
– automatically removed afterward
55. Intercepts = Mocks++
● more general than function mocks
● OO interface – only available from C++
● before() virtual function
– called before the real function
– may change parameters
– may redirect to another function (mocks!)
● after() virtual function
– called after real function returns
– may change return value
56. How Intercepts Work
● a 1-process adaption of how GDB does
breakpoints
● less general
– only works on function entry
– doesn't handle recursive functions
– not very good with threads either
57. How Intercepts Work (2)
.text
process
● intercepts have an install
step
● track and refcount
installed intercepts by
address
● on first install...
r-x
target
function
58. Installing An Intercept
.text
process
rwx
● mprotect() →
PROT_WRITE
● track and refcount pages
● install a SIGSEGV handler
●
overwrite the 1st
byte of
the function
● 0xf4 = HLT
r-x
target
function
59. Calling An Intercepted Function
.text
process
rwx
● the function is called
● CPU traps on HLT
● kernel delivers SIGSEGV
● signal handler is not a
normal function!
– extra stuff on the stack
– signals blocked
– return → magic
r-x
signal
handler
60. Signal Handler
● signal handlers get a ucontext_t struct
– containing the machine register state
– modifiable by the handler!
● check insn at EIP is HLT
– SIGSEGV can also come from bugs!
● stash a copy of the ucontext_t
● set EIP in the ucontext_t to a trampoline
● return from signal handler
● libc+kernel “resumes” to our trampoline
61. Intercept Trampoline
● now out of signal handler context
– stack has the args for the target function
– but running the trampoline
● set up a fake stack frame
● call the intercept's before()
● call the target function with fake frame
– or another function entirely
● call the intercept's after()
● clean up & return to target's caller
62. Complications With Intercepts
● GDB
– need to not use INT3 insn / SIGTRAP
● Valgrind
– need to use INT3 / SIGTRAP
● X86_64 ABI
– 32b relies on 1st
insn being PUSHL %EBP
● the Procedure Linkage Table
● floating point state
63. Parameterised Tests
● when you want to run the same test several
times with a different parameter
● macro NP_PARAMETER
– declares a static string variable
– and all its possible values
● attached to any node in the test tree
● discovered at runtime using reflection
● tests under that node are run once for each
parameter value combination
65. Example 07_parameter
np: running
np: running: "mytest.munchies[pastry=donut]"
I'd love a donut
PASS mytest.munchies[pastry=donut]
np: running: "mytest.munchies[pastry=bearclaw]"
I'd love a bearclaw
PASS mytest.munchies[pastry=bearclaw]
np: running: "mytest.munchies[pastry=danish]"
I'd love a danish
PASS mytest.munchies[pastry=danish]
np: 3 run 0 failed
67. Example 13_twoparams
np: running: "mytest.munchies[pastry=donut][beverage=tea]"
I'd love a donut with my tea
PASS mytest.munchies[pastry=donut][beverage=tea]
np: running: "mytest.munchies[pastry=bearclaw][beverage=tea]"
I'd love a bearclaw with my tea
PASS mytest.munchies[pastry=bearclaw][beverage=tea]
np: running: "mytest.munchies[pastry=danish][beverage=tea]"
I'd love a danish with my tea
PASS mytest.munchies[pastry=danish][beverage=tea]
np: running: "mytest.munchies[pastry=donut][beverage=coffee]"
I'd love a donut with my coffee
PASS mytest.munchies[pastry=donut][beverage=coffee]
np: running: "mytest.munchies[pastry=bearclaw]
[beverage=coffee]"
I'd love a bearclaw with my coffee
PASS mytest.munchies[pastry=bearclaw][beverage=coffee]
np: running: "mytest.munchies[pastry=danish][beverage=coffee]"
I'd love a danish with my coffee
PASS mytest.munchies[pastry=danish][beverage=coffee]
np: 6 run 0 failed
68. Memory Access Violations
● e.g. following a null pointer
● Valgrind notices first and emits a useful
analysis
– stack trace
– line numbers
– fault address
– info about where the fault address points
● child process dies with SIGSEGV or SIGBUS
● test runner process reaps it & fails the test
69. Example 08_segv
np: running: "mytest.segv"
About to follow a NULL pointer
==32587== Invalid write of size 1
==32587== at 0x804AD40: test_segv (mytest.c:22)
…
==32587== by 0x804DEF6: np_run_tests (runner.cxx:665)
==32587== by 0x804ACF6: main (testrunner.c:31)
==32587== Address 0x0 is not stack'd, malloc'd or
(recently) free'd
==32587== Process terminating with default action of
signal 11 (SIGSEGV)
==32587== Access not within mapped region at address
0x0
EVENT SIGNAL child process 32587 died on signal 11
FAIL mytest.crash_and_burn
np: 1 run 1 failed
Valgrind report
test fails gracefully
70. Other Memory Issues
● buffer overruns, use of uninitialised variables
– discovered by Valgrind, as they happen
– which emits its usual helpful analysis
● memory leaks
– discovered by Valgrind, explicit leak check
after each test completes
● test process queries Valgrind
– unsuppressed errors → the test has failed
71. Example 09_memleak
np: running: "mytest.memleak"
About to do leak 32 bytes from malloc()
Test ends
==779== 32 bytes in 1 blocks are definitely lost in loss
record 9 of 54
==779== at 0x4026FDE: malloc …
==779== by 0x804AD46: test_memleak (mytest.c:23)
…
==779== by 0x804DEFA: np_run_tests (runner.cxx:665)
==779== by 0x804ACF6: main (testrunner.c:31)
EVENT VALGRIND 32 bytes of memory leaked
FAIL mytest.memleak
np: 1 run 1 failed
Valgrind report
test fails
72. Code Under Test Calls exit()
● NP library defines an exit()
– yuck, should use dynamic function intercept
● calling exit() during a test
– prints a stack trace
– fails the test
● calling exit() outside a test
– calls _exit()
73. Example 10_exit
np: running: "mytest.exit"
About to call exit(37)
EVENT EXIT exit(37)
at 0x8056522: np::spiegel::describe_stacktrace
by 0x804BD9C: np::event_t::with_stack
by 0x804B0CE: exit
by 0x804AD42: test_exit
by 0x80561F0: np::spiegel::function_t::invoke
by 0x804C3A5: np::runner_t::run_function
by 0x804D28A: np::runner_t::run_test_code
by 0x804D4F7: np::runner_t::begin_job
by 0x804DD9A: np::runner_t::run_tests
by 0x804DEF2: np_run_tests
by 0x804ACF2: main
FAIL mytest.exit
np: 1 run 1 failed
stacktrace from NovaProva
test fails gracefully
74. Code Under Test Emits Syslogs
● dynamic function intercept on syslog()
– installed before each test
– uninstalled after each test
● test may register regexps for expected syslogs
● unexpected syslogs fail the test
75. Running Example 11_syslog
np: running: "mytest.unexpected"
EVENT SLMATCH err: This message shouldn't happen
at 0x8059B22: np::spiegel::describe_stacktrace
by 0x804DD9C: np::event_t::with_stack
by 0x804B9FC: np::mock_syslog
by 0x807A519: np::spiegel::platform::intercept_tramp
by 0x804B009: test_unexpected
by 0x80597F0: np::spiegel::function_t::invoke
by 0x804FB99: np::runner_t::run_function
by 0x8050A7E: np::runner_t::run_test_code
by 0x8050CEB: np::runner_t::begin_job
by 0x805158E: np::runner_t::run_tests
by 0x80516E6: np_run_tests
by 0x804AFC3: main
FAIL mytest.unexpected
stack trace
test fails
76. Example 11_syslog (2)
static void test_expected(void)
{
np_syslog_ignore("entirely expected");
syslog(LOG_ERR, "This message was entirely
expected");
}
Have to tell NP that a
syslog might happen
77. Running Example 11_syslog (2)
np: running: "mytest.expected"
EVENT SYSLOG err: This message was entirely expected
at 0x8059B22: np::spiegel::describe_stacktrace
by 0x804DD9C: np::event_t::with_stack
by 0x804BABA: np::mock_syslog
by 0x807A519: np::spiegel::platform::intercept_tramp
by 0x804B031: test_expected
by 0x80597F0: np::spiegel::function_t::invoke
by 0x804FB99: np::runner_t::run_function
by 0x8050A7E: np::runner_t::run_test_code
by 0x8050CEB: np::runner_t::begin_job
by 0x805158E: np::runner_t::run_tests
by 0x80516E6: np_run_tests
by 0x804AFC3: main
PASS mytest.expected
stack trace
but test passes
78. Slow & Looping Tests
● per-test timeout
– test fails if the timeout fires
● default timeout 30 sec
– 3 x when running under Valgrind
– disabled when running under gdb
● implemented in the testrunner process
– child killed with SIGTERM
79. Example 12_timeout
np: running: "mytest.slow"
Test runs for 100 seconds
Have been running for 0 sec
Have been running for 10 sec
Have been running for 20 sec
Have been running for 30 sec
Have been running for 40 sec
Have been running for 50 sec
Have been running for 60 sec
Have been running for 70 sec
Have been running for 80 sec
EVENT TIMEOUT Child process 2294 timed out, killing
EVENT SIGNAL child process 2294 died on signal 15
FAIL mytest.slow
np: 1 run 1 failed
test times out
after 90 sec
test fails gracefully
runner kills
child process
80. Choosing A Project Name Is Hard
● CUnit has an obvious name
– Unit testing for C
– but … dangerous
● it took me 2 months to name NovaProva
– .org domain not taken
– name didn't sound silly
– sounded vaguely appropriate
● NovaProva ~= “new test” in Italian
81. Remaining Work
● provide an API or a default main() routine to
automatically parse a set of default command
line options, e.g. --list, to simplify building a
testrunner
● class/hashtag concept for test functions
– a syntax for specifying these on the command
line
– how to attach these to test functions in any
kind of natural and reliable way?
82. Remaining Work (2)
● failpoints – a way of automatically failing and
terminating a test if a given function is called,
like exit()
● improve the syntax for specifying tests on the
command line to
– be more flexible e.g. like CSS or XPATH
– allow specifying values for test parameters
● do a better job of running tests in parallel
● .deb and .rpm packages
83. Remaining Work (3)
● port to OS X & Solaris.
● an API for time warping
● an API for timezone manipulation
● an API for locale manipulation
● detect file descriptor leaks
● detect environment variable leaks
● discovery of tests written in C++
● handle C++ exceptions
84. Remaining Work (4)
● enable mocking an entire C++ class
● handle C++ namespaces better in the
reflection API
● support Objective C
● improve the reflection API
– calling functions,
– creating/destroying object instances,
– getting and setting struct data members.
85. Thanks
● Opera Software
– for letting me open source NovaProva
● Cosimo Streppone
– for being Italian
● Andrew Wansink
– for putting me onto CUnit
● Previous LCA conferences
– for giving me testing religion
86. Where To Get It
● www.novaprova.org
● working on binary packages (OBS)
● That's all folks!
Editor's Notes
Jul 1993: first checkins - zero unit tests, zero system tests
... 8779 commits by ~60 people (11 with &gt; 100 commits, 4 with &gt; 1000) ...
Oct 2010: I started working on Cyrus - zero unit tests zero system tests
Nov 2010: I wrote the first unit test