skip to main content
10.1145/2025113.2025145acmconferencesArticle/Chapter ViewAbstractPublication PagesfseConference Proceedingsconference-collections
research-article

Improved multithreaded unit testing

Published:09 September 2011Publication History

ABSTRACT

Multithreaded code is notoriously hard to develop and test. A multithreaded test exercises the code under test with two or more threads. Each test execution follows some schedule/interleaving of the multiple threads, and different schedules can give different results. Developers often want to enforce a particular schedule for test execution, and to do so, they use time delays (Thread.sleep in Java). Unfortunately, this approach can produce false positives or negatives, and can result in unnecessarily long testing time.

This paper presents IMUnit, a novel approach to specifying and executing schedules for multithreaded tests. We introduce a new language that allows explicit specification of schedules as orderings on events encountered during test execution. We present a tool that automatically instruments the code to control test execution to follow the specified schedule, and a tool that helps developers migrate their legacy, sleep-based tests into event-based tests in IMUnit. The migration tool uses novel techniques for inferring events and schedules from the executions of sleep-based tests. We describe our experience in migrating over 200 tests. The inference techniques have high precision and recall of over 75%, and IMUnit reduces testing time compared to sleep-based tests on average 3.39x.

References

  1. A. V. Aho, M. R. Garey, and J. D. Ullman. The transitive reduction of a directed graph. SIAM Journal on Computing, 1972.Google ScholarGoogle Scholar
  2. R. Alur, P. Cerný, M. Parthasarathy, and W. Nam. Synthesis of interface specifications for Java classes. In POPL, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. G. Ammons, R. Bodík, and J. R. Larus. Mining specifications. In POPL, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Apache Software Foundation. Apache Commons Collections. http://commons.apache.org/collections/.Google ScholarGoogle Scholar
  5. Apache Software Foundation. Apache Commons Pool. http://commons.apache.org/pool/.Google ScholarGoogle Scholar
  6. Apache Software Foundation. Apache Lucene. http://lucene.apache.org/.Google ScholarGoogle Scholar
  7. Apache Software Foundation. Apache MINA. http://mina.apache.org/.Google ScholarGoogle Scholar
  8. J. Burnim and K. Sen. DETERMIN: Inferring likely deterministic specifications of multithreaded programs. In ICSE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. H. Carver and K. Tai. Replay and testing for concurrent programs. IEEE Software, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. F. Chen and G. Roşu. Mop: An efficient and generic runtime verification framework. In OOPSLA, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Codehaus. Sysunit. http://docs.codehaus.org/display/SYSUNIT/Home.Google ScholarGoogle Scholar
  12. S. Cotton. graphlib. http://www-verimag.imag.fr/cotton/.Google ScholarGoogle Scholar
  13. A. Dantas, F. V. Brasileiro, and W. Cirne. Improving automated testing of multi-threaded software. In ICST, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. Huang, P. Liu, and C. Zhang. LEAP: Lightweight deterministic multi-processor replay of concurrent Java programs. In FSE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. V. Jagannath, M. Gligoric, D. Jin, G. Rosu, and D. Marinov. IMUnit: Improved multithreaded unit testing (position statement). In IWMSE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. V. Jagannath, Q. Luo, and D. Marinov. Change-aware preemption prioritization. In ISSTA, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Java Community Process. JSR 166: Concurrency utilities. http://g.oswego.edu/dl/concurrency-interest/.Google ScholarGoogle Scholar
  18. JBoss Community. JBoss Cache. http://www.jboss.org/jbosscache.Google ScholarGoogle Scholar
  19. G. Kiczales, E. Hilsdale, J. Hugunin, M. Kersten, J. Palm, and W. G. Griswold. An overview of AspectJ. In ECOOP, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Lassi Project. Sleep testcase. http://tinyurl.com/4hk9zdr.Google ScholarGoogle Scholar
  21. C. Lee, F. Chen, and G. Roşu. Mining parametric specifications. In ICSE, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. B. Long, D. Hoffman, and P. A. Strooper. A concurrency test tool for Java monitors. In ASE, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. B. Long, D. Hoffman, and P. A. Strooper. Tool support for testing concurrent Java components. IEEE TSE, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. P. O. Meredith, D. Jin, D. Griffith, F. Chen, and G. Roşu. An overview of the MOP runtime verification framework. Springer STTT, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. W. Pugh and N. Ayewah. MultithreadedTC - A framework for testing concurrent Java applications. http://code.google.com/p/multithreadedtc/.Google ScholarGoogle Scholar
  26. W. Pugh and N. Ayewah. Unit testing concurrent software. In ASE, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. M. Ricken and R. Cartwright. ConcJUnit: Unit testing for concurrent programs. In PPPJ, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. K. Tai and R. H. Carver. Use of sequencing constraints for specifying, testing, and debugging concurrent programs. In ICPADS, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Improved multithreaded unit testing

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      ESEC/FSE '11: Proceedings of the 19th ACM SIGSOFT symposium and the 13th European conference on Foundations of software engineering
      September 2011
      548 pages
      ISBN:9781450304436
      DOI:10.1145/2025113

      Copyright © 2011 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 9 September 2011

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate17of128submissions,13%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader