vm_test.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Copyright 2014 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package tests
  17. import (
  18. "os"
  19. "path/filepath"
  20. "testing"
  21. )
  22. func BenchmarkVmAckermann32Tests(b *testing.B) {
  23. fn := filepath.Join(vmTestDir, "vmPerformanceTest.json")
  24. if err := BenchVmTest(fn, bconf{"ackermann32", os.Getenv("JITFORCE") == "true", os.Getenv("JITVM") == "true"}, b); err != nil {
  25. b.Error(err)
  26. }
  27. }
  28. func BenchmarkVmFibonacci16Tests(b *testing.B) {
  29. fn := filepath.Join(vmTestDir, "vmPerformanceTest.json")
  30. if err := BenchVmTest(fn, bconf{"fibonacci16", os.Getenv("JITFORCE") == "true", os.Getenv("JITVM") == "true"}, b); err != nil {
  31. b.Error(err)
  32. }
  33. }
  34. // I've created a new function for each tests so it's easier to identify where the problem lies if any of them fail.
  35. func TestVmVMArithmetic(t *testing.T) {
  36. fn := filepath.Join(vmTestDir, "vmArithmeticTest.json")
  37. if err := RunVmTest(fn, VmSkipTests); err != nil {
  38. t.Error(err)
  39. }
  40. }
  41. func TestVmBitwiseLogicOperation(t *testing.T) {
  42. fn := filepath.Join(vmTestDir, "vmBitwiseLogicOperationTest.json")
  43. if err := RunVmTest(fn, VmSkipTests); err != nil {
  44. t.Error(err)
  45. }
  46. }
  47. func TestVmBlockInfo(t *testing.T) {
  48. fn := filepath.Join(vmTestDir, "vmBlockInfoTest.json")
  49. if err := RunVmTest(fn, VmSkipTests); err != nil {
  50. t.Error(err)
  51. }
  52. }
  53. func TestVmEnvironmentalInfo(t *testing.T) {
  54. fn := filepath.Join(vmTestDir, "vmEnvironmentalInfoTest.json")
  55. if err := RunVmTest(fn, VmSkipTests); err != nil {
  56. t.Error(err)
  57. }
  58. }
  59. func TestVmFlowOperation(t *testing.T) {
  60. fn := filepath.Join(vmTestDir, "vmIOandFlowOperationsTest.json")
  61. if err := RunVmTest(fn, VmSkipTests); err != nil {
  62. t.Error(err)
  63. }
  64. }
  65. func TestVmLogTest(t *testing.T) {
  66. fn := filepath.Join(vmTestDir, "vmLogTest.json")
  67. if err := RunVmTest(fn, VmSkipTests); err != nil {
  68. t.Error(err)
  69. }
  70. }
  71. func TestVmPerformance(t *testing.T) {
  72. fn := filepath.Join(vmTestDir, "vmPerformanceTest.json")
  73. if err := RunVmTest(fn, VmSkipTests); err != nil {
  74. t.Error(err)
  75. }
  76. }
  77. func TestVmPushDupSwap(t *testing.T) {
  78. fn := filepath.Join(vmTestDir, "vmPushDupSwapTest.json")
  79. if err := RunVmTest(fn, VmSkipTests); err != nil {
  80. t.Error(err)
  81. }
  82. }
  83. func TestVmVMSha3(t *testing.T) {
  84. fn := filepath.Join(vmTestDir, "vmSha3Test.json")
  85. if err := RunVmTest(fn, VmSkipTests); err != nil {
  86. t.Error(err)
  87. }
  88. }
  89. func TestVm(t *testing.T) {
  90. fn := filepath.Join(vmTestDir, "vmtests.json")
  91. if err := RunVmTest(fn, VmSkipTests); err != nil {
  92. t.Error(err)
  93. }
  94. }
  95. func TestVmLog(t *testing.T) {
  96. fn := filepath.Join(vmTestDir, "vmLogTest.json")
  97. if err := RunVmTest(fn, VmSkipTests); err != nil {
  98. t.Error(err)
  99. }
  100. }
  101. func TestVmInputLimits(t *testing.T) {
  102. fn := filepath.Join(vmTestDir, "vmInputLimits.json")
  103. if err := RunVmTest(fn, VmSkipTests); err != nil {
  104. t.Error(err)
  105. }
  106. }
  107. func TestVmInputLimitsLight(t *testing.T) {
  108. fn := filepath.Join(vmTestDir, "vmInputLimitsLight.json")
  109. if err := RunVmTest(fn, VmSkipTests); err != nil {
  110. t.Error(err)
  111. }
  112. }
  113. func TestVmVMRandom(t *testing.T) {
  114. fns, _ := filepath.Glob(filepath.Join(baseDir, "RandomTests", "*"))
  115. for _, fn := range fns {
  116. if err := RunVmTest(fn, VmSkipTests); err != nil {
  117. t.Error(err)
  118. }
  119. }
  120. }